SQLite wrapper library with C++ core, C API for FFI, and language bindings (Julia, Dart, Python, JS/Bun, plus embedded Lua).
This repo uses nested AGENTS.md files: this root file holds everything cross-cutting; each area's internals live in the AGENTS.md next to it (loaded automatically when working there).
include/quiver/ + src/ # C++ core, Sandbox, binary + expression subsystems -> src/AGENTS.md
src/xlsx/ # Internal XLSX reader, Lua-only (OpenXLSX)
src/json/ # Internal JSON reader, Lua-only (nlohmann/json)
include/quiver/c/ + src/c/ # C API for FFI -> src/c/AGENTS.md
bindings/julia/ # Quiver.jl (canonical; published repo is a mirror) -> bindings/julia/AGENTS.md
bindings/dart/ # quiverdb on pub (ffigen + native-assets hook) -> bindings/dart/AGENTS.md
bindings/python/ # quiverdb on PyPI (CFFI ABI-mode) -> bindings/python/AGENTS.md
bindings/js/ # quiverdb on npm (Bun FFI, hand-written loader) -> bindings/js/AGENTS.md
tests/ # C++/C API suites + shared SQL schemas -> tests/AGENTS.md
.github/ # CI + release/publish workflows, composite actions -> .github/AGENTS.md
scripts/ # build-all/test-all/clean-all.bat, format.bat, tidy.bat,
# generator.bat (runs all three FFI generators),
# assert_version.py (check + bump), validate_wheel*.py + test-wheel-install.bat,
# ci/{dispatch_workflow.sh, native_s3.sh}, julia/generate_artifacts.jl
cmake/ # CompilerOptions.cmake, Dependencies.cmake, Platform.cmake
docs/ # User-facing docs: introduction, rules, attributes, migrations, time_series
assets/ # logo.svg
Top-level configs: CMakePresets.json, .clang-format, .clang-tidy, .clangd,
.gitattributes, .pre-commit-config.yaml, codecov.yml.
- Human-Centric: Codebase optimized for human readability, not machine parsing
- Status: WIP project - breaking changes acceptable, no backwards compatibility required
- ABI Stability: Use Pimpl only when hiding private dependencies; plain value types use Rule of Zero
- Target Standard: C++20 - use modern language features where they simplify logic
- Philosophy: Clean code over defensive code (assume callers obey contracts, avoid excessive null checks). Simple solutions over complex abstractions. Delete unused code, do not deprecate.
- Intelligence: Logic resides in C++ layer. Bindings/wrappers remain thin.
- Error Messages: All error messages are defined in the C++/C API layer. Bindings retrieve and surface them — they never craft their own. The only exception is pre-FFI type-marshalling errors (e.g., Python/Dart rejecting an unsupported value type before the FFI call), which the C API cannot diagnose because the value never reaches it; those messages are crafted locally and should name the offending column and type.
- Homogeneity: Binding interfaces must be consistent and intuitive. API surface should feel uniform across wrappers.
- Ownership: RAII used strictly. Ownership of pointers/resources must be explicit and unambiguous.
- Constraint: Be critical. If code is already optimal, state that clearly. Do not invent useless suggestions just to provide output.
- All public C++ methods should be bound to C API, then to Julia/Dart/Python/JS/Lua (exception: the binary/expression subsystems are exposed only in Julia and Lua by decision — not Dart/Python/JS)
- All *.sql test schemas in
tests/schemas/, bindings reference from there - Self-Updating: Keep the AGENTS.md nearest to your change up to date (root +
src/,src/c/,bindings/{julia,dart,python,js}/,tests/,.github/) - Changelog: user-visible changes get an entry in
CHANGELOG.mdunder the current unreleased version section. Prefix a breaking one BREAKING and say what a caller must do about it. A0.xminor bump signals breaking changes, a patch bump does not — bump accordingly (all five manifests, see Versioning)
Settled questions — don't relitigate without the user; each was decided deliberately:
-
Time-series group data is column-oriented (
{column: [values]}) in every binding — the canonical cross-binding shape. The C++ core keeps row-shapedvector<map<string, Value>>. -
DatabaseOptions(read_only,console_level,log_path) is exposed as optional parameters on the open/factory methods of every binding (logPathin Dart/JS). A nonemptylog_pathnames the log file, enables it even for read-only/in-memory databases, and fails opening on a log error. Relative paths start at the database directory (:memory:uses CWD). Files are truncated on open; spdlog creates parent directories. An unset/empty path keeps the default policy. Database and log paths are UTF-8, including on Windows (spdlog uses wide filenames there). The C API borrows the path only during the call; bindings must keep its storage alive until return. -
Schema metadata loads lazily, on first use (
Impl::require_schema,src/database_impl.h).Database(path, options)— the only implementation behindquiver_database_openand every binding'sopen()— opens the file without reading the schema, so eager loading would have to live in the constructor, where it would validate a half-migrated database beforemigrate_upran. Loading on firstrequire_schemainstead makesopen()usable everywhere (it previously yielded a handle whose every metadata/CRUD call threw "no schema loaded") whilefrom_schema/from_migrationskeep validating eagerly at construction.schemaismutableso the const readers can trigger it, andload_schema_metadatapublishes it only after validation passes, so a failed lazy load leaves nothing published for the next call (a schema published early would never be validated again). A non-quiver database now reports the validator's actual reason. -
The group writers are column-oriented while the group readers are row-oriented in every FFI binding (
read_vector_group_by_idreturns rows in Julia, Dart, Python and JS; Python even adds a synthetic 0-basedvector_index). The only asymmetric reader/writer pair in those bindings, and deliberate for now: the columnar shape is the canonical cross-binding one for group writes (it is what the C API takes), and changing either side is a breaking API change, not a fix. -
Binary + expression subsystems are exposed in Julia and Lua only. Dart, Python, and JS deliberately do not expose them (no FFI consumer); the tests-at-every-layer rule has this one documented exception. Lua binds the C++ classes directly via sol2 (
src/sandbox/binary.cppandsrc/sandbox/expression.cpp) with method syntax + string aggregation operations; pure-metadata builders live under aquiver.*namespace while file I/O is db-scoped (see cross-layer table and the sandbox decision below).helper_maps.jlis a second documented Julia-only exception (see convenience methods below). -
A binary file is an expression. In C++,
BinaryFileandExpression(final) derive fromAbstractExpression(include/quiver/expression/abstract_expression.h), which has one pure virtualnode()and a virtualget_metadata();save,aggregate,aggregate_agents,select_agentsandrename_agentsare non-virtual members built onnode(). Copy and move are protected, so nothing slices or assigns through a base reference. Every operator andabs/sqrt/log/exp/ifelsetakesconst AbstractExpression&per expression operand, thedoubleoverloads stay (ifelsehas none in any layer), andExpression(const AbstractExpression&)isexplicit.BinaryFile::node()returns a fresh path-basedExpressionFile, never the caller's handle:save()opens and closes its inputs, so a node holding the caller's handle would close the caller's reader or writer, and would dangle once the caller closed it. A file'sget_metadata()is the one override: its handle's in-memory metadata. Lua: sol2 checks every operand asconst AbstractExpression&. The base is registered through compile-time traits (SOL_BASE_CLASSESfor each derived type,SOL_DERIVED_CLASSESfor the base, insrc/sandbox/internal.h), because the runtime base-classes tag measured +2.3% on 1Mf:readcalls;AbstractExpressionis never a registered usertype. The last candidate of each overload set keeps the Pattern 1 operand text and raises the too-many-arguments error, and a file takes the six expression methods directly. Julia:abstract type AbstractExpression endinQuiver.jl, withBinary.File <: AbstractExpressionandExpression <: AbstractExpression; every operation is defined once on it and converts a file throughquiver_expression_from_file, andget_metadatais one generic owned byBinary. C API: no abstract or borrowed expression handle, because aquiver_expression_t*that is owned or borrowed depending on where it came from breaks the ownership rule;quiver_expression_from_file(it copies the path) stays the bridge. Rejected: makingExpressionthe abstract type and renaming the concrete one (operations must return a concrete value, Julia'sAbstractArray/Arrayis the naming model, and everyExpression e = a + b;keeps compiling); a node reusing the caller's open handle (above); file-taking variants of everyquiver_expression_*. An open decision: in Lua,==and<between two files, and==between two expressions, are always true (sol2's automatic__eq/__ltover the expression-returning C++ operators); this design leaves that unchanged. -
Lua file operations are db-scoped and sandboxed to the database directory. Every file-touching Lua operation (
db:open_file,db:bin_to_csv,db:csv_to_bin,db:export_csv,db:import_csv,db:validate_migrations,db:read_csv,db:read_csv_stream,db:write_csv,db:read_xlsx,db:read_xlsx_stream,db:read_json,saveon a file or an expression) resolves relative paths against the directory containing the database file and rejects — reads and writes alike — anything that escapes it (subdirectories OK; checked viaweakly_canonicalwith strict containment). In-memory databases (:memory:) reject all file operations. The six writers (db:write_csv,db:export_csv,db:open_filewith mode"w",db:bin_to_csv,db:csv_to_bin,save) go throughRunHandles::resolve_write_pathon top of that, which refuses two more things. One is the database file and its-journal/-wal/-shm(each writer opens with truncate, sodb:write_csv("study.db")zeroed the live database under a host transaction a rollback could not undo; the file is located by SQLite's own absolute name, names compare case-folded and spelled as Win32 opens them (cut at:, trailing dots/spaces dropped), a binary writer checks the files it creates,path+.qvr/.toml/.csv, and a directory named like the journal is refused too, since SQLite could then never open it). The other is any write at all when the host opened the database read-only: the flag is read throughfriend class Sandboxindatabase.h, deliberately not a public accessor that every layer would have to bind. Reads stay available.dofile/loadfileare removed from the Lua environment. String-formloadstays for text chunks only: it always loads with mode"t", so a precompiled binary chunk is refused, because Lua does not verify bytecode. The script given toSandbox::runis loaded with mode"t"too, so a host must pass source, not bytecode. The enabled standard libraries are the pure-computation setbase/string/table/math/coroutine/utf8;os/io/package/debugstay unloaded. Raw SQL cannot bypass the sandbox either:query_*is read-only in every layer (see below), soATTACH,VACUUM INTOand transaction control through SQL are refused. Julia's standaloneopen_fileis unaffected — this is Sandbox policy (resolve_sandbox_pathinsrc/sandbox/path_policy.cpp), not binary-subsystem policy. -
One scalar typing policy lives in C++: an int64 is accepted for INTEGER and REAL columns (int-for-REAL coercion), a double only for REAL (a float into an INTEGER column is rejected), a string for TEXT / DATE_TIME, and an FK label for an INTEGER foreign key wherever
create_element/update_elementor the vector/set group writers resolve it to an id first (the time-series writers take ids only).validate_value(src/type_validator.cpp, scalar create/update) delegates the shape check tovalue_matches_type, which the time-series writers call directly; bindings never coerce schema-dependently.import_csvwrites through a rawINSERT, so it applies the rule to CSV text itself:parse_integer(src/database_csv_import.cpp) andutils::parse_float(src/utils/number.h) accept a cell only if it parses whole, so1.5is not an INTEGER and9.99abc/1,5are not REALs — in the "C" locale's number format whatever locale the host process set, since export always writes..csv_to_binreads its data cells through the sameutils::parse_float. -
Lua element arrays preserve each cell's type.
table_to_elementconverts every dense cell throughlua_to_valueintostd::vector<Value>; C++ validates it against the schema. A REAL array accepts mixed integers, floats and booleans in either order. Empty arrays keep the core's skip-on-create / clear-on-update semantics; nil holes still require group writers. -
A DATE_TIME string is validated on write, and stored verbatim. The accepted grammar is
YYYY-MM-DD, optionally followed byTHH:MM:SSorHH:MM:SS, every field fixed-width and zero-padded, year0001-9999, the calendar day must exist, no leap second; anything else (2005,2005-01,not-a-date,2024-02-31,2024-1-5,2024-01-15T10:30, trailing garbage) is a Pattern 1 rejection naming the column. That band is the intersection of what Python'sfromisoformat, Julia'sDateTimeand Dart'sDateTime.parseall accept — a value the core stores is a value every binding can read, and that is the whole point of the gate, so any change that widens the grammar has to be checked against all three. Being TEXT was previously the only requirement, so an unreadable date landed in the column and detonated later in whichever binding first parsed it, on a read naming neither the write nor the column. One predicate,datetime::is_valid_iso8601(src/utils/datetime.h), is called from both halves of the typing policy above. The core never normalizes — padding a partial date to midnight would makeread_scalar_string_by_idreturn something the caller never wrote (leading/trailing whitespace is the exception:Impl::executetrims every bound string, so the predicate trims too and the gate judges what is actually stored).import_csvis the deliberate exception to "no normalizing": it parses a cell, so it canonicalizes toYYYY-MM-DDTHH:MM:SS(which is what lets an exported date-only value round-trip) — and then runs the same predicate over the canonical string, because import writes through a rawINSERTthatvalidate_valuenever sees. -
update_element/delete_elementthrow on a missing id ("Element not found: <id> in collection '<c>'", Pattern 2) — not a silent no-op. The error surfaces through the C API error channel and every binding. -
query_*validate parameter count:executerejects a mismatch between bound parameters and?placeholders (too few or too many) instead of binding NULL / ignoring extras. -
query_*only runs read-only SQL, in every layer. The SQL may come from an untrusted Lua script, and rawATTACH,VACUUM INTOandCOMMITescaped the filesystem sandbox and the host's transaction.Impl::execute(sql, params, read_only)installs SQLite's authorizer (allowlistSELECT/READ/FUNCTION/RECURSIVE) while the statement compiles and then checkssqlite3_stmt_readonly, which is what catchesVACUUM(the authorizer never sees it). One message:Cannot query: SQL must be read-only; writes, PRAGMA, ATTACH, VACUUM and transaction control are not allowed. Table-valuedpragma_*()functions stay allowed. Writes go through the typed API; tests that must plant invalid data usequiver::test::exec_sql(a second connection). -
Migration
down_sqlis a required feature — do not remove the down path. -
Dry runs live on
Database, not onSandbox.begin_dry_run/end_dry_run/in_dry_runhold one transaction and always roll it back; while active, the publicbegin_transaction/commit/rollbackare absorbed (no-ops). Absorbing is the whole point — without it a script usingdb:transaction(fn)(the pattern the Lua reference recommends) dies on a nestedBEGIN. Adry_run(bool)parameter onSandbox::runwas implemented first and rejected: it duplicated transaction semantics inside the Lua binding layer and gated the feature behind Lua for no reason. Consequences, all documented rather than fixed: a nested rollback is not partial (everything is undone at the end regardless);in_transaction()still reportstrue;import_csvstill throws itstransaction already activeprecondition; and a caller could once escape via a rawCOMMITthroughquery_*— closed now thatquery_*is read-only, butend_dry_runkeeps guarding onsqlite3_get_autocommitinstead of throwing, as defense. A per-table changeset (SQLite session extension) was skipped — a script that wants a change count already hasSELECT total_changes(). -
A script cannot end a scope the host opened.
Sandbox::runsnapshots, at entry, whether a dry run is open and whether a plain transaction is; a scope open then is the host's, including one an earlierrun()left open. The Luadb:commit()/db:rollback()throw Pattern 1 under a host transaction (Cannot commit: the transaction was open before the script started, so it belongs to the host) anddb:end_dry_run()under a host dry run. Under a host dry runcommit/rollbackstill reachDatabaseand are absorbed, as the decision above requires. This is the same escape 0.13.4 closed for a rawCOMMITthroughquery_*, through the typed API: the host-dry-run pattern was escapable withdb:end_dry_run(), and both agent hosts (harness, claw) wrappeddbin a Lua table proxy to block it. Only ending is refused; a nesteddb:begin_transaction()/db:transaction(fn)under a host transaction still throwstransaction already active— absorbing it (a committing sibling ofbegin_dry_run) would touch this decision and the no-SAVEPOINTs one, so it is the maintainer's call. A snapshot rather than tracking who opened the scope: tracking goes stale when the host ends a script's transaction through FFI and opens its own. Outsiderun()every scope counts as the host's, because Lua still runs then:lua_closecalls the script's__gcfinalizers when the Sandbox is destroyed. The FFIcommit/rollbackare untouched. -
Writers check everything before their first write, and there are no SAVEPOINTs.
Impl::TransactionGuardno-ops inside a caller-owned transaction or a dry run, so it cannot roll back a failed call there. Every writer that can run inside one therefore resolves and validates all of its input before its first INSERT/UPDATE/DELETE (import_csvcannot: it refuses to nest and rolls back its own transaction). The group and time-series writers already do;create_element/update_elementused to write the scalar row before checking their arrays (a Luapcallinsidedb:transactioncommitted half a call), and now route, FK-resolve and validate every array inImpl::prepare_group_datafirst. The documented limit is what only SQLite checks: a UNIQUE / PRIMARY KEY, NOT NULL, CHECK or foreign-key failure on an INSERT, or a trigger that raises (a set written{"a", "a"}, a NULL cell in a NOT NULL group column, a NOT NULL column the call leaves out — e.g. adate_timearray, which every time-series group of the collection shares, written to a group whose value column the call does not name) still throws after the call's earlier writes, and inside a caller-owned transaction those writes stay for the commit. Autocommit calls are still all-or-nothing. A SAVEPOINT per nested guard would close that gap and was rejected in the v0.3 research (commitf92af8d, "SAVEPOINT Complexity Leaking Into the Design") as the nesting complexity the no-op guard exists to avoid. -
Sandbox::runreturns the script's return value as a JSON string. One encoder in C++ (src/sandbox/return_json.cpp, anonymous namespace); every binding passes the string through without parsing, so no binding gains a JSON dependency (Julia would have needed one). Only the first returned value is encoded; noreturnyields"", distinct fromreturn nil→"null". Non-finite numbers becomenull, a table keyed1..nis an array ({}→[]) and any other table is a key-sorted object — so a nullable bulk read, which Lua represents asnilholes, comes back as an object ({"1":10,"3":30}), not[10,null,30]. A function/coroutine/userdata throws, as does nesting past 32 levels (the cycle guard), output past 64 MiB (the size cap — depth alone does not bound a table that shares sub-tables), a string that is not valid UTF-8 (JSON must be UTF-8, a Lua string need not), and a table where an integer key and a string key spell the same thing (two Lua keys, one JSON key — refused rather than silently dropped). -
Sandbox::runtakes an optional, soft time limit (run(script, timeout_ms), 0 = none, negative throws). It is checked between Lua instructions (a count hook firing every 10000, which coroutines inherit) and between SQLite VM steps (a progress handler), and fails the script withCannot run: script exceeded its time limit of <N> ms. No Lua call that catches an error can swallow it (pcall,xpcalland its handler,coroutine.resume/close/wrap,load's reader): the prelude's wrappers re-raise once the deadline has passed. Both are removed atrun()'s exit, beforeGcGuard's collection, so the host's next calls are never interrupted. The ceiling is deliberate: a long read query is interrupted, but work outside the Lua VM and SQLite's (an expressionsave, an XLSX load,export_csv's file write, a Lua string pattern match, a write — the progress handler never interrupts a write, because SQLite would roll back the whole transaction, the host's included) finishes first; Lua runs__gcfinalizers, and the__closeof a coroutine the limit killed, with hooks off, so a loop inside one is not stopped; and memory stays uncapped. A hard limit means a separate process. A timeout behaves like any script error (db:transaction(fn)rolls back; a scope the script opened by hand stays open). It is the one in-process limit every binding can use: Bun's FFI call and Julia'sccallblock the thread a host timer would need, and a Python timer thread (CFFI releases the GIL) has no API it could call to stop the script. A set limit costs a tight pure-Lua loop about 2x (Lua 5.4 traps every instruction while a hook is set); no limit, no cost. -
import_csvrefuses to run inside an open transaction — Pattern 1 precondition, not a silent rollback. Import must own its transaction (aTransactionGuard, rolled back on any error): nested inside a caller's, the guard would no-op, so a failure partway through would leave import's earlier writes, its DELETEs included, for the caller's commit. The original reason (import toggledPRAGMA foreign_keys, a no-op mid-transaction) is gone: import now keeps foreign keys on throughout. Whether to let it nest instead is an open decision for the maintainer. -
BinaryMetadata::number_of_time_dimensions()is derived fromdimensions, never stored.TimeProperties::initial_valueis the deliberate opposite: it is stored, because the per-cell traversal (next_dimensions,ExpressionAggregate::compute_row) reads it, and it is computed only byBinaryMetadata::derive_initial_values(), whichbuild_metadata(behind bothfrom_toml_contentandfrom_element) and theExpressionAggregateconstructor call. Do not turn it into an on-read derivation. -
A binary time coordinate names a calendar cell, and a week starts on the day of
initial_datetime. An inner time value is its position inside the parent's period (day of month/year/week, hour of day/month/year/week);add_offset_from_intsteps from period starts: yearly and monthly steps start from January 1 / the 1st, never frominitial_datetime's day of the month, so month ends and leap years cannot shift a cell, and a week is seven days counted frominitial_datetime's day, never from January 1. One function,position_in_parent(src/binary/binary_utils.h), yields both the initial values and the read/write check. Details insrc/AGENTS.md("Time Coordinates"). -
One C API error channel: everything (Sandbox included) reports via
quiver_get_last_error; no per-handle error channels. -
Python's
Elementis internal; users pass**kwargsto create/update. -
JS keeps a string-based datetime surface — no DateTime wrappers.
-
Lua has no row-aligned whole-group readers.
read_vector_group_by_id/read_set_group_by_idare not bound;db:read_vectors_by_id/db:read_sets_by_idread each column independently. The per-column readers now preserve NULL cells asnilholes, so cell i of every column of one group is the same row — but a Lua inner list has no count authority (read_element_idscounts elements, not rows, and vectors/sets have no dimension column), so a trailing NULL is invisible ([10, NULL]reads as{10}) and a NULL-only row reads as{}, exactly like no rows; the JSON result cannot tell them apart either. Only aNOT NULLcolumn of the group gives the row count. Accepted rather than fixed: a sentinel would break the "nilis NULL" rule the time-series and scalar readers share, and a script that needs exact row shape does that read in the host binding. Pinned byReadVectorPreservesNullCellsAsNilHoles; recorded in the agent-facing Lua reference (bindings/js/src/sandbox-api.ts). -
Boolean wrappers are Julia/Dart/Python/JS only; Lua is deliberately excluded. SQLite has no boolean type, so a boolean lives in an INTEGER column as 0/1 and the wrappers are a strict-conversion convenience with no C++ or C API counterpart (the fourth documented per-binding omission, alongside JS-datetime, binary/expression, and the Lua whole-group readers above). The exclusion is read-side only — see the write-side policy below, which every layer including Lua now honours. Lua needs no readers: it has a native boolean, and a script that wants one writes
read_scalar_integers(...)[i] == 1. What it gives up is the strict-conversion gate below, not just sugar:== 1maps a stray2tofalserather than raising, and anilfrom a NULL cell is not equal to 0 (nil ~= 0istruein Lua), so the tempting~= 0spelling reads a NULL astrue. If a column's 0/1-ness has to be enforced, aCHECK (col IN (0, 1))in the schema does it at write time for every layer and for raw SQL alike, which is where that belongs. The conversion is strict: only 0 and 1 convert; any other integer raises the binding's native conversion error (ArgumentErrorin Julia and Dart,ValueErrorin Python,RangeErrorin JS) naming the offendingcollection.attribute. This is one of the few locally-crafted messages — the core never sees these readers, so it cannot diagnose a stray2. On the write side a boolean is accepted wherever an integer is, in every layer including Lua:create_element/update_element(scalars and arrays), query parameters, the vector/set/time-series group writers, andupsert_time_series_row— all mapping it to INTEGER 1/0, which therefore also reaches a REAL column through the int-for-REAL coercion. There is no boolean setter in the C API and none is needed: each binding converts before the FFI call (Element.setin Dart,setElementField/setElementArray/marshalParams/updateGroupColumns/upsertRowColumnsin JS,lua_to_value/lua_cell_asinsrc/sandbox/internal.h). Julia and Python need no conversion branch becauseBool <: Integerandboolis anintsubclass respectively, so a boolean takes each writer's integer branch. That is worth a test rather than an assumption: in Julia the group and row marshallers are branch-order-dependent (Bool <: Realtoo, so theirIntegertest must precede theRealone), and in Python it holds only while every write path testsisinstance(v, int)—type(v) is intwould reject a bool (pinned bytest_boolean_inputinbindings/python/tests/test_database_boolean.py).db:update_relationis the one deliberate refusal: onlynilmay clear a relation. All of them return one entry per element, aligned withread_element_ids, and all preserve NULLs positionally — the scalar readers per element, the vector/set readers per cell. -
Binary
dimsparameter is the map-based form only — indexed overloads were prototyped and deliberately dropped (perf rationale insrc/AGENTS.md). -
update_time_series_filesandupsert_time_series_rowpatch: an unnamed column is not a written column. A named column takes the caller's value, a null included; an unnamed one keeps what it has. Lua cannot write NULL through either:{ x = nil }is{}, so omission is Lua's only signal and it means preserve — the same limitation Lua has oncreate_element/update_elementscalars, and a write-only sentinel would be a valueread_time_series_filescould never emit. Anilcell inupdate_time_series_groupstill writes NULL. Nothing else patches:create_element/update_elementarrays and the group writers each rebuild the unit they address and NULL an unnamed column.update_time_series_files: with no existing row there is nothing to keep, so an unnamed column is NULL.upsert_time_series_rowusedINSERT OR REPLACE, which rebuilt the row and silently nulled every column the caller left out. Now an existing row gets anUPDATEof the named columns only; a missing row is inserted, its unnamed columns taking their DEFAULT. Mechanism, and why it is not oneON CONFLICT DO UPDATE:src/AGENTS.md. Only the primary key addresses a row, so a second UNIQUE constraint raises instead of replacing, and a row naming only dimension columns creates the row if absent and otherwise writes nothing.
-
Time-series group NULLs round-trip via a per-cell presence mask. The columnar C API (
read/update/free_time_series_data) carries auint8_tmask parallel to the data arrays (NULL mask = dense;mask[c][r] == 0= SQL NULL, data ignored — so an all-NULL column can be FLOAT-tagged against any schema column). FFI bindings (Julia/Python/Dart/JS) read null-padded columns and accept null cells on update; their existing equal-length validations stay. Lua is mask- and sentinel-free: NULL is plainnil, the dimension column(s) are the row-count authority (#ts.<dimension>), value columns may be short/sparse/empty (missing cells write NULL), longer-than-dimension errors, and the named-but-empty anti-silent-clear trap is preserved ({}clears). -
Element arrays accept NULL cells. C++
Element::set(name, std::vector<Value>)stores null cells directly (a nullable group column, e.g. an optional relation, can have empty cells per row);create_element/update_elementbind them as SQL NULL. The C API array setters (quiver_element_set_array_{integer,float,string}) carry the same trailingconst uint8_t* has_valuepresence mask as the time-series writers (NULL mask = dense;has_value[i] == 0= SQL NULL, data slot ignored; a NULLchar*entry in a string array is also NULL). Dart'sElement.setacceptsList<T?>with null cells and empty lists (an empty or all-null list is tagged integer — the type is irrelevant when no value is read); Julia/Python/JS pass a dense (NULL) mask and keep their non-null surfaces. -
Scalar bulk reads preserve NULLs positionally (one entry per element).
read_scalar_{integers, floats,strings}returnstd::vector<std::optional<T>>in C++ (mirroring the_by_idvariants); a SQL NULL isnullopt, aligned withread_element_idsbyORDER BY rowid— NULLs are never dropped. The C API numeric readers carry a paralleluint8_t* out_mask(mask[i] == 0= NULL, data slot is a 0/0.0 placeholder) freed byquiver_database_free_mask; the string reader needs no mask — a NULL is anullptrentry in thechar**. Python/Dart/JS always return the nullable element type (list[T|None]/List<T?>/(T|null)[]) — a static surface with no type-inference instability to fix. Julia is nullability-aware:read_scalar_{integers,floats, strings}return a concreteVector{T}forNOT NULLcolumns andVector{Optional{T}}for nullable ones (decided byget_scalar_metadata(...).not_null, schema- not data-driven), so a column that can never be NULL gives downstream code a concrete array. AnINTEGER PRIMARY KEY(e.g.id) is a rowid alias and is reportednot_nullby the C++ core (scalar_metadata_from_column, even though SQLite'sPRAGMA table_infoleaves the flag unset), soidreads are concreteVector{Int64}. Scope of that Julia rule is the readers whose optional comes solely from NULL cells — the bulk scalar readers and all twelve vector/set readers (vialist_{vector,set}_groups(...)); scalar_by_id/query_*(optional also from missing-id / unknown result nullability) and the time-series readers stay optional — tracked inbindings/julia/type_stability_followup.md. Lua usesnilholes (onlyto_lua_tablechanged; no C API mask) withread_element_idsas the count/position authority since#tis unreliable across holes. The vector/set readers followed the same rule (see the next decision). -
Bulk reads of one collection are positionally aligned, and cells preserve NULLs.
read_element_ids,read_scalar_*and the six vector/set bulk readers all order by the collection'srowid, so entry i is the same element in every one of them — the convention that makes zipping several attributes per element correct. The vector/set readers used to break it by skipping elements with no group rows; they now LEFT JOIN the group table onto the collection, so such an element is an empty inner vector (no signature changed, so the bindings inherited the fix). Alignment holds between calls, so a caller reading several attributes alongside a concurrent writer needs a read transaction around the whole group. Don't make a reader self-sufficient by callingread_element_idsinside it: two statements are two snapshots, the same race moved inside the library. Cell NULLs used to be dropped by the vector/set readers ([0.10, NULL, 0.30]→[0.10, 0.30]), which made two per-column reads of one nullable group mis-pair; they are now preserved positionally (std::optional/nothing/None/null/nil), so zipping per-column reads of a group is correct — provided each column name resolves to that group. A per-column reader resolves a name to the group named after it when that group holds the column (a group may be named after another group's column), else to the group of that kind whose table name sorts first among those holding it, so when two vector or two set groups share a column name (legal for FK columns) the name reads one of them for both. Theread_{vectors,sets}_by_idcomposites read and key by column name, so they inherit that;read_{vector,set}_group_by_idread the group they are given, in every binding. The LEFT JOIN carries a presence column (g.id) to keep "no group row" and "NULL cell" apart: no row at all is an empty inner list, a row whose value is NULL is a null cell. The C ABI carries the same distinction — a per-celluint8_tmask for the numeric readers (freed byquiver_database_free_masksin bulk,quiver_database_free_maskby id) and anullptrentry for the string ones.read_vector_group_by_id/read_set_group_by_idremain the row-shaped readers, but no longer the only NULL-correct ones. -
A set group's rows come back in
rowidorder, and that order is not a promise. All the set readers (read_set_*,read_set_*_by_id,read_set_group_by_id)ORDER BY rowid. The_by_idreaders had noORDER BYat all, so each took the order of whichever index SQLite picked for it: a set table with two UNIQUE constraints is legal (validate_set_tablechecks their union), and there two per-column reads of one group came back in different orders and paired the wrong values together.rowidis also the only stable row identity a set table has — SQLite's UNIQUE treats each NULL as distinct, so once cells can be NULL no value-based order is total. Document it as consistent across every reader of the group, otherwise unspecified: it happens to equal write order (the group writers delete and re-insert), and that coincidence must not become a contract. -
db:read_csv(path, opts)/db:read_csv_stream(path, on_row, opts)are Lua-only, with no counterpart anywhere else — no public C++ header, no C API, no Julia/Dart/Python/JS binding. The firstdb:methods with no counterpart in any other layer, and the newest member of the documented per-binding omission list alongside JS-datetime, the binary/expression subsystems, and the Lua whole-group readers above. The reason is the one the requirements give: every other host already has a native CSV library, and Lua needs this precisely becauseiois deliberately absent from its sandbox. Both forms are mounted on one internal reader (quiver::csv_read::Reader,src/csv/csv_read.h/.cpp, no public header) so they cannot diverge on any input; every cell arrives as a string with no numeric or date inference; the options table takes two keys —separator(a single-character string, defaulting to,) andheader_row(1-based, defaulting to1;0declares the file has no header at all). Both names are sandboxed like every other Lua file operation (see the sandbox decision above). Writing is exposed too, symmetric in kind but streaming-only:db:write_csv(path, opts)returns a handle,w:write_row(row)appends one row, andw:close()finishes it — no whole-file form, since a second code path is a second thing that can diverge. Like the reader, the writer is Lua-only with no C++ header, no C API, and no FFI binding; it shares the sameresolve_sandbox_pathgate, truncates an existing file at open with no overwrite guard, takes the same two options (separatorandheader) and no more, and formats numbers viastd::to_chars's shortest round-trip form — anilcell and an empty-string cell are indistinguishable after the round trip, since CSV has no null. With aheader, its length is the row width:write_rowpads a shorter row with empty cells and throws a Pattern 1 error naming the row ordinal and both counts for a longer one; omittingheaderdisables the check entirely. A writer still open when the callingSandbox::runreturns is closed atrun()'s scope exit — covering the throw path too — so the file is complete and re-readable even if the script never calledw:close(), with no warning emitted. That close goes through aweak_ptrregistry of every writer the run handed out, not through the GC:collect_garbage()alone only finalizes writers the script made unreachable, so a writer held in a Lua global left a 0-byte file (seesrc/AGENTS.md). A writer does not outlive itsrun(). -
One CSV parser, one CSV emitter. csv-parser, through
csv_read::Reader(src/csv/csv_read.cpp), parses for bothimport_csvanddb:read_csv*;csv_write::append_record(src/csv/csv_write.cpp) emits for bothexport_csvanddb:write_csv, so those four share one quoting rule (quote a cell iff it holds the separator,", CR or LF). The reader preserves valid UTF-8 fields and decodes invalid ones as ISO-8859-1, for headers and cells alike, without rewriting input files. This per-field fallback is shared by Lua CSV reads andimport_csv. The binary subsystem'sbin_to_csv/csv_to_binare not on this path: they split and join on,and never quote, so a label holding a comma does not round-trip. Their numbers do share the stack: data cells are written byutils::append_numberand read byutils::parse_float, the same pairexport_csv/import_csvuse, so a value round-trips exactly in every host locale. rapidcsv, which import and export used before, was dropped. Its whole-document reader cannot backdb:read_csv_stream's bounded memory, and its auto-quote quoted on a space but not on", so"x"exported raw and read back asx. Import's other old bugs came from Quiver's own pre-pass, deleted along with it: every;rewritten to,, asep=line missed after a BOM, and a per-line trailing-comma strip that cut into quoted multi-line cells. What import still does itself, insniff_csv_file/read_csv_file: it reads thesep=line (or, with none, a header line holding;and no,) to choose the separator, and it drops Excel's trailing empty columns. It also runsrequire_well_formed_quotesbefore parsing. Do not remove that check. csv-parser keeps text after a closing quote as a literal and stays inside the quote, so"a" ,b\n"c",dparses as one row whose cell count can still match the header, and import deletes before it writes (a scalar import every element the CSV omits, a group import the whole group table). The check judges import's own read of the file while csv-parser re-reads it by name, so that read fails closed: a regular file it cannot read in full is rejected rather than judged empty (a byte-range lock failsReadFilebut not csv-parser's mapped reads).db:read_csvis read-only and deliberately stays lenient. -
JSON reads are Lua-only, like CSV/XLSX reads:
db:read_json(path)parses one UTF-8 JSON document through the internalsrc/json/json_read.h/.cpphelper and nlohmann/json v3.12.0 (header-only, private build dependency). Objects become string-keyed tables, arrays use 1-based indices, strings/booleans keep their types, signed-64-bit integers stay integers and other finite numbers become Lua doubles (large integers may round). JSON null isnil: object fields vanish, array holes keep their original indices, trailing nulls disappear and#is not a count authority. Empty objects and arrays both become empty Lua tables; the existing return encoder therefore emits[]for either, and sparse arrays as objects. Input is bounded to 64 MiB and depth 32 (root depth 0); file/parse/limit errors carryCannot read_json:and the caller's path. The parser's default strict syntax and duplicate-key last-value-wins policy apply. No public C++ method, C API or host-binding reader is added. -
XLSX reads are Lua-only, like CSV reads:
db:read_xlsx(path, opts)anddb:read_xlsx_stream(path, on_row, opts)sharexlsx_read::Reader(internal Pimpl,src/xlsx/xlsx_read.h/.cpp). No public C++ header, C API or host-binding reader. Options aresheet(exact name or 1-based worksheet index, default 1, chart sheets excluded) andheader_row(physical row, default 1, 0 means no header). Cells are strings; numeric/date serials stay their stored text, booleans are "1"/"0", blanks are "", rich text is flattened, Excel errors stay text and formulas require saved caches (no evaluation). Blank data rows are skipped; width is the last column containing a value/formula, ignoring formatting-only extents. The callback uses CSV's exact-false stop and delivered-row count. OpenXLSX v0.5.1 loads worksheet XML/shared strings in memory; the callback avoids the full Lua rows table, not the XML DOM.CheckedArchivevalidates XML before OpenXLSX can silently ignore a parse failure. Neither reader saves, extracts ZIP entries to disk or follows external links.
Reviewed adversarially and rejected — these are not improvements:
- Collapsing per-method FFI boilerplate in Dart/Python into closure-parameterized helpers — the expanded style is the de facto convention; helpers add pointer-type indirection for marginal gain.
- Deleting or "cleaning up"
tests/sandbox— intentional scratch target. - "Simplifying" the documented Bun FFI workarounds (
bindings/js/AGENTS.md) or the binary hot-path decisions (src/AGENTS.md) — load-bearing. - Drive-by fixing pre-existing lint debt in untouched JS files.
- Relocating the agent-facing Lua reference (
bindings/js/src/sandbox-api.ts,SANDBOX_API_REFERENCE). Moving it into the C++ layer would turn a build-time constant into a runtime FFI call just to assemble a system prompt, and would make a one-sentence docs fix a native republish across npm libs, PyPI wheels, Julia artifacts, and S3 natives. Moving it to an imported.mdwas implemented, verified, and reverted — editing ergonomics only, at the cost of afiles-allowlist dependency and a Bun text-loader floor. Neither fixes drift, which is what actually went wrong; the sync test does. Rationale inbindings/js/AGENTS.md.
Plain python / python3 / py are not on PATH in this environment. Run Python through
uv instead — it provisions the interpreter and dependencies on the fly:
uv run python -c "..." # ad-hoc script
uv run --with pyyaml python -c "..." # with a one-off dependency (e.g. validate a workflow YAML)(CI runners invoke python3 directly; this uv note is for local/agent use only.)
cmake --build build --config DebugFirst-time configure (what build-all.bat does):
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DQUIVER_BUILD_TESTS=ON -DQUIVER_BUILD_C_API=ONscripts/build-all.bat # Build everything + run all tests (Debug)
scripts/build-all.bat --release # Build in Release mode
scripts/test-all.bat # Run all tests (assumes already built)test-all.bat runs the six suites below; build-all.bat builds and then calls test-all.bat
(breakdown in tests/AGENTS.md).
./build/bin/quiver_tests.exe # C++ core library tests
./build/bin/quiver_c_tests.exe # C API tests
bindings/julia/test/test.bat # Julia tests
bindings/dart/test/test.bat # Dart tests
bindings/js/test/test.bat # JavaScript (Bun) tests
bindings/python/tests/test.bat # Python tests./build/bin/quiver_cli.exe # CLI entry point: runs a Lua script against a database (--help)
./build/bin/quiver_benchmark.exe # Transaction benchmark - run manually, never in CIWhen the C API changes:
scripts/generator.bat # all three generators in sequence, or individually:
bindings/julia/generator/generator.bat # Julia (Clang.jl -> src/c_api.jl)
bindings/dart/generator/generator.bat # Dart (ffigen -> lib/src/ffi/bindings.dart)
bindings/python/generator/generator.bat # Python (prints cdecls as a diff aid for _c_api.py)JS has no generator — update the hand-written symbol table in bindings/js/src/loader.ts.
- CMake ≥ 3.26, C++20. Options:
QUIVER_BUILD_SHARED(ON),QUIVER_BUILD_TESTS(ON),QUIVER_BUILD_C_API(OFF — the configure line above turns it on),QUIVER_UNVERSIONED_SHARED(OFF). When scikit-build-core drives the build (Python wheels) it defines theSKBUILDCMake variable, which forces C API ON and tests OFF. Wheel installs set the C API's RPATH to@loader_pathon macOS and$ORIGINon Linux so it resolves the bundled core in the same_libsdirectory. QUIVER_UNVERSIONED_SHAREDomits VERSION/SOVERSION, so the shared libraries are built as plainlibquiver.dylib/libquiver.soreal files instead of a versioned real file plus unversioned symlinks. Only the Dart hook sets it (bindings/dart/hook/build.dart), becausefindAndAddCodeAssetswalks withfollowLinks: falseand matches the unversioned name — so with versioning on it registers nothing and reports success. Leave it OFF everywhere else: Julia hardcodeslibquiver.0.dylib, andscripts/ci/native_s3.shandpublish-s3.ymlship the versioned names by name.CMAKE_PLATFORM_NO_VERSIONED_SONAMEis not a substitute — under the Xcode generator the hook uses, it drops the symlinks but keeps the versioned file name. Only the Linux Dart Coverage CI job exercises the ON configuration (through the hook); no macOS or Windows job does.- macOS builds are floored at deployment target 13.3 (
cmake/Platform.cmake): libc++ marks the floating-pointstd::to_charsused bydatabase_csv_export.cpp,sandbox/return_json.cpp,sandbox/csv.cppandbinary/csv_converter.cpp(all throughutils::append_number) unavailable below it, so that is the core's floor, not one binding's. A higher explicitCMAKE_OSX_DEPLOYMENT_TARGETis respected; a lower one is raised. Do not remove it: with no floor, clang stamps the builder's own OS version into every dylib, which is how the published Julia/JS/S3 natives ended up requiring whatever macOS the CI runner image was. The Dart hook passes its ownDEPLOYMENT_TARGETas well, because native_toolchain_cmake's iOS toolchain file force-derivesCMAKE_OSX_DEPLOYMENT_TARGETfrom it beforePlatform.cmakeis read. - Presets (
CMakePresets.json):dev(Debug) andrelease(Release), both Ninja with tests and the C API ON, each with a matching build and test preset. They build intobuild/<presetName>/; the plainbuild/directory is the manual configure above. No script or CI job uses them — they are for IDEs and ad-hoc Release test runs. - Dependencies via FetchContent (
cmake/Dependencies.cmake): sqlite3 v3.53.4 (psrenergy/sqlite3-cmake, PSR's fork of the archived sjinks wrapper; built thread-safe, serialized —sqlite3_ENABLE_THREADSAFEis FORCEd ON so a stale cache cannot keep it at 0), tomlplusplus v3.4.0, spdlog v1.17.0, lua v5.4.8 (lua-cmake wrapper — itslua_bin/luac_binare unconditionaladd_executables inall, so a plaincmake --build builddoes build two binaries this project never uses; lua-cmake has no switch for them, so theLUA_BUILD_INTERPRETER/LUA_BUILD_COMPILERonce set here were no-ops, andEXCLUDE_FROM_ALLis not a fix either — see the note incmake/Dependencies.cmake), sol2 v3.5.0 (its safety checks are on in every build —SOL_ALL_SAFETIES_ON, withSOL_PRINT_ERRORS=0so caught errors are not printed — except the checked getter and the stack check, which are off for cost; details insrc/AGENTS.md), csv-parser v5.3.0 (csvtarget, the only CSV library — behindcsv_read::Reader, which serves Luadb:read_csv*andimport_csv; fetchedGIT_SHALLOW, andCSV_NO_SIMD/CSV_ENABLE_THREADS/CSV_BUILD_PROGRAMS/CSV_BUILD_TESTSare all FORCEd; theCSV_NO_SIMDpin is load-bearing — without it a PUBLIC/arch:AVX2propagates intoquiverand SIGILLs on pre-AVX2 x86 for every shipped wheel/native), argparse v3.2, googletest v1.17.0 (tests only). OpenXLSX v0.5.1 is private and static (miniz 3.0.2, pugixml 1.15, nowide 11.3.1 on Windows); its CMake policy-floor override is scoped to the dependency for CMake 4. Documentation/examples/tests/benchmarks/LTO are disabled. nlohmann/json v3.12.0 is header-only and build-only; its tests and installation are disabled. - Targets:
quiver(core),quiver_c,quiver_cli,quiver_tests,quiver_c_tests,quiver_benchmark,quiver_sandbox. Outputs: executables/DLLs →build/bin/, libs →build/lib/. There is noinstall()/find_package(quiver)package: a C++ consumer adds Quiver withadd_subdirectory/FetchContent and linksquiver/quiver_c. The onlyinstall()rule is the SKBUILD one that puts both libraries into the Python wheel'squiverdb/_libs.
CMakeLists.txt project(... VERSION x.y.z) is the single source of truth.
scripts/assert_version.py asserts that bindings/python/pyproject.toml,
bindings/js/package.json, bindings/dart/pubspec.yaml, and bindings/julia/Project.toml
all agree — bump all five together. The same script also writes them:
scripts/assert_version.py bump major|minor|patch rewrites all five and prints the new version,
refusing to run from a state where they already disagree. Normally you dispatch the Bump
Version workflow instead, which runs exactly that and opens the PR. CHANGELOG.md carries the
version too (## [x.y.z] — unreleased plus its compare link) but is edited by hand — the
release ritual for that file is not settled. Release flow: .github/AGENTS.md.
scripts/format.bat— C++ via the CMakeformattarget (clang-format), then each binding's ownformat.bat(JuliaFormatter, dart format, ruff, biome).- clang-format is pinned to 22.1.8: CI runs the PyPI wheel through
uvx, pre-commit usesmirrors-clang-formatat the same rev, and the CMakeformattarget prefersclang-format-22..clang-formatuses 22-only keys (theBreakAfterOpenBracket*/BreakBeforeCloseBracket*spelling of BlockIndent), which clang-format 21 rejects as a config error, so bump all three together. scripts/tidy.bat—run-clang-tidyoverbuild/compile_commands.json(strips the MinGW-only-fno-keep-inline-dllexportflag first; skipssrc/binary; findsrun-clang-tidyon PATH, and the header filter lives in.clang-tidy)..pre-commit-config.yaml— trailing-whitespace, end-of-file, yaml/json checks, merge-conflict markers, large files (>1 MB), LF line endings, clang-format, cppcheck..gitattributes(* text=auto eol=lf) forces LF for every text file in the working tree,.batincluded, whatevercore.autocrlfsays (SmartGit and Git for Windows set it to true). It markstests/fixtures/*.csv-textso their exact bytes (BOM, CRLF) are never normalized —.pre-commit-config.yamlexcludes the same directory fromtrailing-whitespace/end-of-file-fixer/mixed-line-ending, since-textonly stops git's own conversion, not a hook's.
All throw std::runtime_error(...) in the C++ layer use exactly 3 message patterns:
Pattern 1 -- Precondition failure: "Cannot {operation}: {reason}"
throw std::runtime_error("Cannot create_element: element must have at least one scalar attribute");Validators thread the calling operation's name through so the {operation} is the public method
the user called (e.g., type mismatches report "Cannot update_element: ...").
Pattern 2 -- Not found: "{Entity} not found: {identifier}"
throw std::runtime_error("Scalar attribute not found: 'value' in collection 'Items'");Pattern 3 -- Operation failure: "Failed to {operation}: {reason}"
throw std::runtime_error("Failed to open database: " + sqlite3_errmsg(db));No ad-hoc formats in the database core. Downstream layers (C API, bindings) can rely on
consistent error structure. Known exception: the binary/expression subsystem's metadata
validation throws descriptive messages (e.g. "Number of labels must be positive, got 0")
that predate the pattern; new code should use the three patterns.
Every schema must have a Configuration table:
CREATE TABLE Configuration (
id INTEGER PRIMARY KEY,
label TEXT UNIQUE NOT NULL
) STRICT;CREATE TABLE MyCollection (
id INTEGER PRIMARY KEY AUTOINCREMENT,
label TEXT UNIQUE NOT NULL,
-- scalar attributes
) STRICT;Named {Collection}_vector_{name} with composite PK:
CREATE TABLE Items_vector_values (
id INTEGER NOT NULL REFERENCES Items(id) ON DELETE CASCADE ON UPDATE CASCADE,
vector_index INTEGER NOT NULL,
value REAL NOT NULL,
PRIMARY KEY (id, vector_index)
) STRICT;Named {Collection}_set_{name} with UNIQUE constraint:
CREATE TABLE Items_set_tags (
id INTEGER NOT NULL REFERENCES Items(id) ON DELETE CASCADE ON UPDATE CASCADE,
value TEXT NOT NULL,
UNIQUE (id, value)
) STRICT;Named {Collection}_time_series_{name} with a dimension (ordering) column: the first primary-key column after id whose name starts with date_ (e.g., date_time), stored as ISO 8601 text (YYYY-MM-DDTHH:MM:SS). Any other date_ column is an ordinary value column:
CREATE TABLE Items_time_series_data (
id INTEGER NOT NULL REFERENCES Items(id) ON DELETE CASCADE ON UPDATE CASCADE,
date_time TEXT NOT NULL,
value REAL NOT NULL,
PRIMARY KEY (id, date_time)
) STRICT;Named {Collection}_time_series_files, singleton table for file path references:
CREATE TABLE Items_time_series_files (
data_file TEXT,
metadata_file TEXT
) STRICT;Always use ON DELETE CASCADE ON UPDATE CASCADE for parent references. validate_schema enforces
it for every vector, set and time-series table: the table's prefix must name an existing
collection, and its id must reference that collection with both actions. Every other foreign
key, in any table, must use ON UPDATE CASCADE with ON DELETE CASCADE or ON DELETE SET NULL
(a SET NULL column must be nullable).
Public Database methods follow verb_[category_]type[_by_id]:
- Verbs: create, read, update, upsert, delete, get, list, has, query, describe, export, import
_by_idsuffix: Only for reads where both "all elements" and "single element" variants exist_by_labelsuffix: Label-addressed counterpart of an id-addressed write. Spelled out in every layer including the ones that could overload (C++, Julia, Lua) — one name everywhere, no type dispatch. The label form resolves and delegates to the id form; it never re-implements it.- Singular vs plural: Type name matches return cardinality (
read_scalar_integersreturns vector,read_scalar_integer_by_idreturns optional) - Examples:
create_element,read_vector_floats_by_id,get_scalar_metadata,list_time_series_groups
- Factory methods:
from_schema(),from_migrations()—DatabaseOptions(read_only,console_level,log_path) exposed as optional parameters in every binding.from_migrationswithread_onlyapplies no migrations and creates no database: it loads theui/sidecar for a database with no pending migrations, and throws Pattern 1 (... a read-only open cannot apply them) for one behind them;from_schemarefusesread_only. A read-only open creates no default log, but an explicitlog_pathenables one. A Sandbox over it cannot write files through Lua file operations; the host's ownexport_csvon that handle still writes, as the host asked. validate_migrations(migrations_path)— validates a migrations directory (up then down) against a throwaway in-memory database; no out-parameter, returns nothing. Bound in every layer, including Lua (db:validate_migrations, db-scoped and sandboxed — see the design decision above). A directory with no numbered migration subdirectories is an error here, and so is a round trip that ends with tables still standing.- Transaction control:
begin_transaction(),commit(),rollback(),in_transaction() - Dry runs:
begin_dry_run(),end_dry_run(),in_dry_run()— one transaction that is always rolled back; while active the three transaction methods above are absorbed (no-ops) so nested callers compose. See the design decision below. - CRUD:
create_element(collection, element),update_element,delete_element,update_element_by_label(collection, label, element),delete_element_by_label(collection, label). An empty array clears its group onupdate_element/update_element_by_labeland is skipped bycreate_element(pinned in the core byDatabase.UpdateElementEmptyArrayClearsRowsandDatabase.CreateElementWithEmptyArraySkipsSilently); Lua passes an empty array through as well since 0.13.0 (it used to skip it). - Label-addressed writes: each
_by_labelform resolves the label within the collection (Impl::resolve_label) and delegates to its id counterpart, so everything past the lookup — CASCADE, the attribute writes, the validation — is the id form's. A label is unique per collection, not per database. Errors name the step that raised them: the lookup owns the Pattern 2 miss (Element not found: label 'x' in collection 'C'), while the delegated write names the id form (Cannot update_element: ...). Passinglabelamong the attributes toupdate_element_by_labelrenames the element; the lookup has already run, so the write lands on the resolved id. - Relation updates:
update_relation(collection_from, collection_to, relation_type, id, target_label)andupdate_relation_by_label(..., label, target_label)derive the relation column aslowercase(collection_to) + "_" + relation_type, verify that it is a foreign key tocollection_to, and write the target label;std::nulloptclears the relation. The write delegates toupdate_element, so the FK-label resolution and the Pattern 2 missing-id check are that method's. This is the scalar-relation writer: a relation that lives in a vector, set, or time-series group is a list of targets, so it is written by the group writer that owns it. Bound in every layer: C++, the C API (a NULLtarget_labelclears), Julia, Dart, Python, JS, and Lua — where a missing argument also clears, and a non-string one throws. - Element count:
number_of_elements(collection)returns the current row count from the collection's main table (COUNT(*)), not its maximum ID or group-row count. Any table in the schema is accepted, so naming a group table reports that table's own row count. - Scalar/vector/set readers:
read_{scalar,vector,set}_{integers,floats,strings}(collection, attribute)(+_by_idvariants). All the bulk readers return one entry per element, aligned withread_element_ids— an element with no group rows is an empty inner vector, never skipped. Every one of them preserves SQL NULLs positionally (std::optional/nothing/None/null/nil): the scalar readers per element, the vector/set readers per cell. See the two NULL design decisions. - Whole-group readers:
read_vector_group_by_id()/read_set_group_by_id()— row-shapedvector<map<string, Value>>over all of a group's value columns, positionally aligned with SQL NULL cells preserved (Value{nullptr}). One call for a whole group, where zipping the per-column_by_idreaders takes N; both are NULL-correct now that the per-column readers preserve cells. C API mirrorsread_time_series_group's columnar+mask shape (freed byfree_time_series_data). Julia, Dart, Python and JS all call it and return rows, read from the named group's own table in one statement — so, unlike zipping per-column reads, a column name another group of the same kind shares cannot pull that group's rows in (see the bulk-reads decision). A SQL NULL isnothing/null/None/null, a DATE_TIME column is parsed except in JS (string datetime surface), and Python adds a synthetic 0-basedvector_index. Lua does not bind them (design decision). - Whole-group writers:
update_vector_group()/update_set_group()— replace all of an element's rows in one named group; an empty row list clears it. The write counterpart of the readers above, and the unambiguous alternative to passing arrays throughupdate_element/create_element: those route an array by column name, so when two groups of a collection share a column name (legal —validate_no_duplicate_attributesexempts FK columns) the array is written to every matching table, silently rewriting groups the caller never named. That fan-out is pinned byUpdateElementSharedColumnNameWritesEveryMatchingGroupand now logs a warning (tests/schemas/valid/relations.sqlsharesparent_refacross a vector and a set group). Prefer the group writers whenever one group is meant. Bound in every layer: C++, the C API (columnar + per-cell mask, same shape asupdate_time_series_group), Julia, Dart, Python, JS, and Lua;update_vector_group_by_label/update_set_group_by_labelare their label-addressed forms. Validation lives in the C++ core and is shared by all of them: the caller's columns are checked against the group (the union of every row's keys, so a column named only in a later row is written and an unknown one still throws),id/vector_indexare rejected as caller-supplied columns (they are derived, and emitting one would duplicate it in the INSERT where SQLite keeps the first occurrence — silently discarding the caller's value), the element id must exist (Pattern 2Element not found), and validation precedes the DELETE so a rejected write cannot leave a cleared group even whenTransactionGuardowns no transaction (inside a dry run or a caller-owned transaction). A named column with no rows is an error, not a clear — clearing is "no columns" — so a typo'd column name cannot destroy data; that guard sits in the C API decoder (the last layer where column names still exist) and in Lua, and coversupdate_time_series_grouptoo. Not yet fixed: the deep fix for the array fan-out — rejectingmatches.size() > 1whendelete_existing— is still open. Onlybindings/julia/test/test_helper_maps.jldepends on the fan-out, and viacreate_element!(the non-destructive half), so nothing blocks it; it is a breaking behaviour change rather than a bug fix. - Time series:
read_time_series_group(),update_time_series_group(),update_time_series_group_by_label(),upsert_time_series_row(),upsert_time_series_row_by_label()— group read/update use N typed value columns per group;upsert_time_series_rowinserts or patches a single row by its dimension key (see the patch-semantics decision above). All bindings expose group data column-oriented ({column: [values]}); updating with no data clears the group. Integer values are accepted for REAL columns (converted on insert). NULL cells round-trip through every layer: the C API carries a per-cell presence mask, the FFI bindings surface null-padded columns (nothing/None/null), and Lua uses plainnilholes with the row count taken from the dimension column(s) — see the design decision below. - Time series row:
read_time_series_row(collection, group, attribute, date_time)— one value per element using "last non-null value at or before date_time" semantics; null Value for elements with no matching data (bindings surfacenothing/null/None/nil). Single-dimension groups only: a group with more than one dimension column (every PK column butid, e.g.date_time+block) holds several rows per date, so it throws Pattern 1Cannot read_time_series_row: group '<g>' of collection '<c>' has more than one dimension columneven on an empty collection — such a group is read withread_time_series_group. The query also filters NULL in its outer join, not only in the latest-date subquery. The C API carries that null as a presence mask (out_mask, one entry per element for every data type, freed byquiver_database_free_mask), and Julia returnsVector{Optional{T}}for every column type. - Time series files:
has_time_series_files(),list_time_series_files_columns(),read_time_series_files(),update_time_series_files()— the writer patches: only the named columns are written, a named column takes the caller's value (explicit NULL included), an unnamed one keeps its current value (see the design decision above). An emptyupdate_time_series_filesmap still validates the collection and its files table (an unknown collection, or one with no_time_series_filestable, throws) and then changes nothing — in every layer: the FFI bindings forward it ascount == 0with NULL or zero-length arrays and never return early. - Metadata:
get_{scalar,vector,set,time_series}_metadata()— group metadata is a unifiedGroupMetadatawithdimension_column(populated for time series, empty for vectors/sets) - List groups:
list_scalar_attributes(),list_vector_groups(),list_set_groups(),list_time_series_groups()— all four throw Pattern 1Cannot <op>: collection not found: <c>for a name that is not a table (an existing collection with no groups of that kind is an empty list), and theread_vectors_by_id/read_sets_by_idcomposites inherit that throw. - Query:
query_string/integer/float(sql, parameters = {})- parameterized, read-only SQL with positional?placeholders (anything but a read throwsCannot query: SQL must be read-only; ..., see the design decision).Row::get_floatwidens an INTEGER value (the same int64-for-REAL rule as the scalar typing policy), so it applies to every float read —query_float,read_scalar_floats,read_scalar_float_by_id,read_vector_floats_by_id,read_set_floats_by_id— not just queries. OtherwiseSELECT COUNT(*)/SUM(int_col), which SQLite answers as INTEGER, and an integer stored in a REAL column, all read back as "no value".query_integerdoes not narrow a REAL; that direction is lossy. - Schema inspection — text reports for agents (both return
std::string):describe_collection(c)combines structure, UI metadata (including tooltips), scalar null/non-null counts and low-cardinality integer distributions, and per-group coverage. Declarations and statistics share each line, with; label,; enum {code: "label"}and; tooltipclauses between them. Enum meanings appear only inenum {...}; histograms contain numeric codes and counts.describe()returns its database/version header followed by the exact complete report for every collection, querying statistics for each one. Every sidecar clause is present only when the database was opened viafrom_migrations(the sole path that loads the sidecar) and only for main-table scalars — group columns render bare. CSV:export_csv(),import_csv()with optional enum/date formatting viaCSVOptions. Export and import are symmetric on foreign keys: a FK column is written as the referenced element'slabeland read back by label (self-references are excluded on both sides, since the target rows are the ones being rewritten). Export used to emit the raw integer id, which import then rejected — so any table with a relation could not round-trip. Floats are written withstd::to_chars(shortest exact round-trip);%gwas used first and silently truncated to 6 significant digits. A scalarimport_csvmakes the collection match the CSV by label, with foreign keys on: an element whose label is in the file is updated in place (its id, group rows and inbound relations survive), a new label is inserted, and an element the file omits is deleted exactly asdelete_elementwould delete it — its group rows cascade away and every relation to it follows itsON DELETEaction (SET NULLclears it,CASCADEdeletes the referencing row, which can be an element of another collection). A label may appear only once, and an import whose deletions would cascade into an element the CSV keeps (a CASCADE cycle through another collection) is refused and rolled back. Import used to switch foreign keys off and delete-then-reinsert every row, which orphaned the omitted elements' group rows and left relations pointing at deleted ids. Mechanism and ordering:src/AGENTS.md.
Builder for element creation with fluent API:
Element().set("label", "Item 1").set("value", 42).set("tags", {"a", "b"}).qvr binary file I/O with .toml metadata sidecars (BinaryFile, bin_to_csv/csv_to_bin,
BinaryMetadata) and lazy arithmetic expressions over them (Expression DAGs with
broadcast, aggregation, and label projection, materialized via save()). Exposed in Julia
(FFI) and Lua (sol2). BinaryFile and Expression share the AbstractExpression base, so a file
takes every expression operation and method in C++, Lua and Julia; the C API converts a file with
quiver_expression_from_file(). Full reference: src/AGENTS.md.
print() writes one INFO entry to the database's current logger and flushes it immediately.
Arguments use Lua's tostring and tab separators; the logger supplies its usual prefix/newline.
Writable databases default to quiver_database.log; read-only/in-memory databases default to
console only. A host-provided log_path selects the file in every mode. console_level filters
only the console. There is no separate sandbox log or output API. The CLI accepts --log-path
and uses the same policy (--log-level info shows prints on stderr); stdout holds JSON results.
Executes Lua scripts against a database; the db userdata exposes the same API surface
(see cross-layer tables below). run(script, timeout_ms = 0) returns the script's return value
encoded as JSON (empty string if it returned nothing) — every binding passes that string
through verbatim. timeout_ms > 0 is a soft wall-clock limit (design decision above). The binding
lives in src/sandbox/, one file per core file it binds (database.cpp and database_*.cpp,
named after src/database*.cpp), plus csv.cpp, json.cpp, xlsx.cpp, binary.cpp and
expression.cpp; the layout and its rules are in src/AGENTS.md, along with the implementation
notes.
- C++ to C API: Prefix
quiver_database_to the C++ method name. Example:create_element->quiver_database_create_element - C++ to Julia: Same name. Add
!suffix for mutating operations (create, update, delete). Example:create_element->create_element! - C++ to Dart: Convert
snake_casetocamelCase. Factory methods use named constructors:from_schema->Database.fromSchema() - C++ to Python: Same
snake_casename. Factory methods are@staticmethod. Properties are regular methods (not@property). Create/update use**kwargs:create_element("Collection", label="x"). - C++ to JS: Same camelCase rule as Dart, with
Csvcased asexportCsv/importCsv. - C++ to Lua: Same name exactly (1:1 match). Lua has no lifecycle methods (open/close) -- database is provided as
dbuserdata by Sandbox.
The rules are mechanical: given any C++ method name, you can derive the equivalent in any layer.
| Category | C++ | C API | Julia | Dart | Lua |
|---|---|---|---|---|---|
| Factory | Database::from_schema() |
quiver_database_from_schema() |
from_schema() |
Database.fromSchema() |
N/A |
| Open existing | Database(path, options) |
quiver_database_open() |
open() |
Database.open() |
N/A |
| Validate migrations | Database::validate_migrations() |
quiver_database_validate_migrations() |
validate_migrations() |
Database.validateMigrations() |
db:validate_migrations() |
| Transaction | begin_transaction() |
quiver_database_begin_transaction() |
begin_transaction!() |
beginTransaction() |
begin_transaction() |
| Transaction | commit() |
quiver_database_commit() |
commit!() |
commit() |
commit() |
| Transaction | rollback() |
quiver_database_rollback() |
rollback!() |
rollback() |
rollback() |
| Transaction | in_transaction() |
quiver_database_in_transaction() |
in_transaction() |
inTransaction() |
in_transaction() |
| Dry run | begin_dry_run() |
quiver_database_begin_dry_run() |
begin_dry_run!() |
beginDryRun() |
begin_dry_run() |
| Dry run | end_dry_run() |
quiver_database_end_dry_run() |
end_dry_run!() |
endDryRun() |
end_dry_run() |
| Dry run | in_dry_run() |
quiver_database_in_dry_run() |
in_dry_run() |
inDryRun() |
in_dry_run() |
| Create | create_element() |
quiver_database_create_element() |
create_element!() |
createElement() |
create_element() |
| Read scalar | read_scalar_integers() |
quiver_database_read_scalar_integers() |
read_scalar_integers() |
readScalarIntegers() |
read_scalar_integers() |
| Read by Id | read_scalar_integer_by_id() |
quiver_database_read_scalar_integer_by_id() |
read_scalar_integer_by_id() |
readScalarIntegerById() |
N/A (use composites) |
| Update | update_element() |
quiver_database_update_element() |
update_element!() |
updateElement() |
update_element() |
| Update by label | update_element_by_label() |
quiver_database_update_element_by_label() |
update_element_by_label!() |
updateElementByLabel() |
update_element_by_label() |
| Delete | delete_element() |
quiver_database_delete_element() |
delete_element!() |
deleteElement() |
delete_element() |
| Delete by label | delete_element_by_label() |
quiver_database_delete_element_by_label() |
delete_element_by_label!() |
deleteElementByLabel() |
delete_element_by_label() |
| Update relation | update_relation() |
quiver_database_update_relation() |
update_relation!() |
updateRelation() |
update_relation() |
| Update relation by label | update_relation_by_label() |
quiver_database_update_relation_by_label() |
update_relation_by_label!() |
updateRelationByLabel() |
update_relation_by_label() |
| Element count | number_of_elements() |
quiver_database_number_of_elements() |
number_of_elements() |
numberOfElements() |
number_of_elements() |
| Metadata | get_scalar_metadata() |
quiver_database_get_scalar_metadata() |
get_scalar_metadata() |
getScalarMetadata() |
get_scalar_metadata() |
| List groups | list_vector_groups() |
quiver_database_list_vector_groups() |
list_vector_groups() |
listVectorGroups() |
list_vector_groups() |
| Time series read | read_time_series_group() |
quiver_database_read_time_series_group() |
read_time_series_group() |
readTimeSeriesGroup() |
read_time_series_group() |
| Time series row | read_time_series_row() |
quiver_database_read_time_series_row() |
read_time_series_row() |
readTimeSeriesRow() |
read_time_series_row() |
| Time series upsert row | upsert_time_series_row() |
quiver_database_upsert_time_series_row() |
upsert_time_series_row!() |
upsertTimeSeriesRow() |
upsert_time_series_row() |
| Time series upsert row by label | upsert_time_series_row_by_label() |
quiver_database_upsert_time_series_row_by_label() |
upsert_time_series_row_by_label!() |
upsertTimeSeriesRowByLabel() |
upsert_time_series_row_by_label() |
| Time series update | update_time_series_group() |
quiver_database_update_time_series_group() |
update_time_series_group!() |
updateTimeSeriesGroup() |
update_time_series_group() |
| Time series group update by label | update_time_series_group_by_label() |
quiver_database_update_time_series_group_by_label() |
update_time_series_group_by_label!() |
updateTimeSeriesGroupByLabel() |
update_time_series_group_by_label() |
| Vector group update | update_vector_group() |
quiver_database_update_vector_group() |
update_vector_group!() |
updateVectorGroup() |
update_vector_group() |
| Vector group update by label | update_vector_group_by_label() |
quiver_database_update_vector_group_by_label() |
update_vector_group_by_label!() |
updateVectorGroupByLabel() |
update_vector_group_by_label() |
| Set group update | update_set_group() |
quiver_database_update_set_group() |
update_set_group!() |
updateSetGroup() |
update_set_group() |
| Set group update by label | update_set_group_by_label() |
quiver_database_update_set_group_by_label() |
update_set_group_by_label!() |
updateSetGroupByLabel() |
update_set_group_by_label() |
| Vector group read | read_vector_group_by_id() |
quiver_database_read_vector_group_by_id() |
read_vector_group_by_id() |
readVectorGroupById() |
N/A (not bound — design decision) |
| Set group read | read_set_group_by_id() |
quiver_database_read_set_group_by_id() |
read_set_group_by_id() |
readSetGroupById() |
N/A (not bound — design decision) |
| Query | query_string() |
quiver_database_query_string() |
query_string() |
queryString() |
query_string() |
| CSV | export_csv() |
quiver_database_export_csv() |
export_csv() |
exportCSV() |
export_csv() |
| Describe (text) | describe() |
quiver_database_describe() |
describe() |
describe() |
describe() |
| Describe collection | describe_collection() |
quiver_database_describe_collection() |
describe_collection() |
describeCollection() |
describe_collection() |
| CSV file read | N/A | N/A | N/A | N/A | db:read_csv() / db:read_csv_stream() |
| XLSX file read | N/A | N/A | N/A | N/A | db:read_xlsx() / db:read_xlsx_stream() |
| JSON file read | N/A | N/A | N/A | N/A | db:read_json() |
| CSV file write | N/A | N/A | N/A | N/A | db:write_csv() / w:write_row() / w:close() |
Binary cross-layer examples (Julia + Lua subsystem):
| Category | C++ | C API | Julia | Lua |
|---|---|---|---|---|
| Open file | BinaryFile::open_file(path, mode, md?) |
quiver_binary_file_open_file() |
open_file(path; mode, metadata=nothing) |
db:open_file(path, mode, md?) |
| Close | (destructor) | quiver_binary_file_close() |
close!(file) |
file:close() |
| Read | binary_file.read(dims) |
quiver_binary_file_read() |
read(file; dims...) |
file:read(dims, allow_nulls?) |
| Write | binary_file.write(data, dims) |
quiver_binary_file_write() |
write!(file; data=data, dims...) |
file:write(data, dims) |
| Get metadata | x.get_metadata() |
quiver_binary_file_get_metadata() / quiver_expression_get_metadata() |
get_metadata(x) |
x:get_metadata() |
| Is an expression | class BinaryFile : public AbstractExpression |
quiver_expression_from_file() (copies the path) |
Binary.File <: AbstractExpression |
every operator, quiver.* expression function and method takes a file |
| Save | x.save(path) |
quiver_expression_save() |
save(x, path) |
x:save(path) |
| Aggregate | x.aggregate(dim, op, p?), x.aggregate_agents(op, p?) |
quiver_expression_aggregate(), quiver_expression_aggregate_agents() |
aggregate(x, dim, op, p?), aggregate_agents(x, op, p?) |
x:aggregate(dim, op, p?), x:aggregate_agents(op, p?) |
| Select / rename agents | x.select_agents(labels), x.rename_agents(mapping) |
quiver_expression_select_agents(), quiver_expression_rename_agents() |
select_agents(x, labels), rename_agents(x, mapping) |
x:select_agents(labels), x:rename_agents({old=new}) |
| Get file path | binary_file.get_file_path() |
quiver_binary_file_get_file_path() |
get_file_path(file) |
file:get_file_path() |
| Bin to CSV | bin_to_csv() |
quiver_csv_converter_bin_to_csv() |
bin_to_csv() |
db:bin_to_csv(path, aggregate?) |
| CSV to bin | csv_to_bin() |
quiver_csv_converter_csv_to_bin() |
csv_to_bin() |
db:csv_to_bin(path) |
| Metadata from keywords | BinaryMetadata::from_element() |
quiver_binary_metadata_from_element() |
Metadata(; kwargs...) |
quiver.metadata{kwargs} |
| Metadata from TOML | BinaryMetadata::from_toml_content() |
quiver_binary_metadata_from_toml() |
from_toml_content() |
quiver.metadata_from_toml() |
| Metadata from Element | BinaryMetadata::from_element() |
quiver_binary_metadata_from_element() |
from_element() |
quiver.metadata_from_element() |
x is a file or an expression; the C API's expression functions take a quiver_expression_t*, so
a file goes through quiver_expression_from_file() first.
The Lua expression surface mirrors Julia's: a binary file is an expression, so a file handle
takes every operator, quiver.* expression function and method directly, and
quiver.expression(f) still converts one explicitly. Compose with the + - * / operators and unary - (metamethods, with
scalar-on-either-side and file_a + file_b both supported), unary math via quiver.abs/sqrt/log/exp,
element-wise comparisons via quiver.gt/lt/gte/lte/eq/neq (free functions — Lua comparison
metamethods can't return an Expression; produce 1.0/0.0, NaN operand → NaN), boolean logic
via the & / | / ~ operators (bitwise metamethods, since and/or/not are Lua keywords;
nonzero is true, unitless result, NaN propagates), quiver.ifelse(cond, then, else), and the
methods, on x a file or an expression: x:aggregate(dim, op[, p]) /
x:aggregate_agents(op[, p]) / x:select_agents(labels) / x:rename_agents({old=new}) /
x:save(path) / x:get_metadata() (a file's is its handle's metadata; saving from a file reads it
by path and leaves the handle open). A wrong operand raises Cannot <op>: operand must be an expression or a binary file, got <type>; extra arguments to a quiver.* expression function or a
directly called operator metamethod raise Cannot <op>: too many arguments (expected N, got M),
and the methods ignore extra arguments like every other method. Aggregation op is a string
("sum"/"mean"/"min"/"max"/"percentile") — Lua has no enums, mirroring JS's string-based surface.
Lua file I/O is db-scoped (db:open_file, db:bin_to_csv, db:csv_to_bin) and save paths, on
a file or an expression, are sandboxed to the database directory (see Design Decisions).
The bindings provide additional convenience methods that compose core operations. These have no direct C++ or C API counterpart. (JS deliberately keeps a string-based datetime surface — no DateTime wrappers.)
DateTime wrappers (Julia, Dart, and Python):
| Julia | Dart | Python | Wraps |
|---|---|---|---|
read_scalar_date_times |
readScalarDateTimes |
read_scalar_date_times |
string scalar bulk read + date parsing |
read_scalar_date_time_by_id |
readScalarDateTimeById |
read_scalar_date_time_by_id |
string read + date parsing |
read_vector_date_times |
readVectorDateTimes |
read_vector_date_times |
string vector bulk read + date parsing |
read_vector_date_times_by_id |
readVectorDateTimesById |
read_vector_date_times_by_id |
string vector read + date parsing |
read_set_date_times |
readSetDateTimes |
read_set_date_times |
string set bulk read + date parsing |
read_set_date_times_by_id |
readSetDateTimesById |
read_set_date_times_by_id |
string set read + date parsing |
query_date_time |
queryDateTime |
query_date_time |
string query + date parsing |
The three parsers (string_to_date_time, stringToDateTime, _parse_datetime) each gate their
input to the core's DATE_TIME grammar — YYYY-MM-DD optionally plus THH:MM:SS or HH:MM:SS,
fixed-width, year 0001-9999, a real calendar day — and reject anything else with a locally
crafted message naming collection.attribute, the boolean-wrapper rule. They must accept exactly
the same set: that intersection is what the core's write gate exists to guarantee, and each host
parser is wider than it in a different direction (Julia fills missing trailing components, Python's
fromisoformat and Dart's DateTime.parse take Z/offset forms, and Dart additionally rolls an
out-of-range field over rather than rejecting it). The write gate only fires on date_-prefixed
columns, so a plain TEXT column is the path by which a non-conforming value reaches a reader.
Like the boolean family, all of them return one entry per element, aligned with
read_element_ids, and all preserve NULLs positionally — the scalar readers per element, the
vector/set readers per cell.
Boolean wrappers (Julia, Dart, Python, and JS):
| Julia | Dart | Python | JS | Wraps |
|---|---|---|---|---|
read_scalar_booleans |
readScalarBooleans |
read_scalar_booleans |
readScalarBooleans |
integer scalar bulk read + strict 0/1 conversion |
read_scalar_boolean_by_id |
readScalarBooleanById |
read_scalar_boolean_by_id |
readScalarBooleanById |
integer scalar by-id read + strict 0/1 conversion |
read_vector_booleans |
readVectorBooleans |
read_vector_booleans |
readVectorBooleans |
integer vector bulk read + strict 0/1 conversion |
read_vector_booleans_by_id |
readVectorBooleansById |
read_vector_booleans_by_id |
readVectorBooleansById |
integer vector by-id read + strict 0/1 conversion |
read_set_booleans |
readSetBooleans |
read_set_booleans |
readSetBooleans |
integer set bulk read + strict 0/1 conversion |
read_set_booleans_by_id |
readSetBooleansById |
read_set_booleans_by_id |
readSetBooleansById |
integer set by-id read + strict 0/1 conversion |
query_boolean |
queryBoolean |
query_boolean |
queryBoolean |
integer query + strict 0/1 conversion |
Composite read helpers (all five bindings):
| Julia | Dart | Python | Lua | JS | Wraps |
|---|---|---|---|---|---|
read_scalars_by_id |
readScalarsById |
read_scalars_by_id |
read_scalars_by_id |
readScalarsById |
list_scalar_attributes + typed reads |
read_vectors_by_id |
readVectorsById |
read_vectors_by_id |
read_vectors_by_id |
readVectorsById |
list_vector_groups + typed reads |
read_sets_by_id |
readSetsById |
read_sets_by_id |
read_sets_by_id |
readSetsById |
list_set_groups + typed reads |
read_element_by_id |
readElementById |
read_element_by_id |
read_element_by_id |
N/A | scalars + vectors + sets merged |
Relation map helpers (Julia only): bindings/julia/src/helper_maps.jl provides
scalar_relation_map / set_relation_map, which derive the FK column name from the naming
convention (lowercase(collection_to) * "_" * relation_type) and map each element to the
positional index of its related element. A documented Julia-only convenience for PSR's
modeling tooling — a deliberate exception to the thin-bindings rule, kept in the binding
because only Julia consumers use it.
Transaction block wrappers (Julia, Dart, Python, JS, and Lua):
| Julia | Dart | Python | JS | Lua | Wraps |
|---|---|---|---|---|---|
transaction(db) do db...end |
db.transaction((db) {...}) |
with db.transaction(): |
db.transaction((db) => ...) |
db:transaction(function(db)...end) |
begin + fn + commit/rollback |
dry_run(db) do db...end |
db.dryRun((db) {...}) |
with db.dry_run(): |
db.dryRun((db) => ...) |
db:dry_run(function(db)...end) |
begin_dry_run + fn + end_dry_run |
The JS pair is synchronous only (every FFI call is): a Promise-returning fn would commit or end
the dry run before its awaited work ran.
Scoped resource factories (Julia and Python — no Dart/JS equivalent): the four bindings sit in
three shapes and the divergence is not yet resolved. Julia has callback-first overloads for do
syntax on Database (open, from_schema, from_migrations) and Binary.File (open_file);
Python has with on Database and Sandbox; Dart and JS have neither. All of them wrap
open + fn + close. Two caveats hold wherever a scoped form exists: a Sandbox borrows its
Database (raw Database& in src/sandbox/sandbox.cpp) and must not outlive the block, and an
uncommitted transaction still open at the block's exit is rolled back by the close.