# SQLite Engine agent guide SQLite Engine carries the full SQLite 3.54.1 source tree (`upstream/`) and ports engine components to Ziran one step at a time. The first component, `src/Varint.zi`, decodes SQLite file-format varints and is exercised by C differential tests. The separate `ziranlang/sqlite` binding owns the public SQL API; this repository owns the engine fork. ## Layout - `upstream/` — imported SQLite source, byte for byte; never edit. Verify against the Fossil check-in and the published SHA3-256 when refreshing. - `src/` — Ziran components. `ziran.toml` exports `Varint = src/Varint.zi`. - `tests/` — the `varint_test.c` differential decoder suite and the compatibility suite (SQL, file interop, recovery; Python 3 + GNU stdbuf). - `plans/rewrite.md` — compatibility gates and the binding integration contract. - `Makefile` — every build and test entry point; `build/` holds outputs. ## Commands - `make -j2 native` — configure and build `sqlite3`, `libsqlite3.a/.so` under `build/baseline/` (--disable-tcl --disable-readline --enable-fts5). - `make test-varint` — decoder differential suite with ASan/UBSan. - `make test-compat` — isolated SQL/file/recovery compatibility suite. - `make -j2 check` — both suites plus `ziran check --locked`. - `make -j2 upstream-test` — SQLite's source verifier and veryquick runner; needs Tcl and Tcl development headers (override with `TCL_CONFIG=`, `TCLSH=`). ## Pins - Toolchain: `ziran.lock` pins ziran.git `b5b8167f1814f629028dbbd3e1dc831eee9b2a8a`. - Baseline: SQLite 3.54.1, Fossil `555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76`; archive SHA3-256 `877c6f4996ce7adb368686bce21638de9e3d91534832ad3d9d119037d1bc22ad`; amalgamation digest `e2b869d3003b33c942b7dd7063604fbc53553e1b66609570df39b9b7b558ee81`. ## Question -> file - How do I build or test? -> `Makefile`, README "Build and test". - Where is the Ziran code? -> `src/` (exports in `ziran.toml`). - What is ported next, and which gates apply? -> `plans/rewrite.md`. - How do I refresh upstream? -> README "Updates and compatibility". - Which toolchain or baseline identity? -> `ziran.lock` and the pins above.