You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Key finding:** No implementation was needed. SQLite's native statement/transaction semantics already provide the required atomicity guarantees. The Zig changes vtab sets `xBegin`, `xCommit`, `xRollback` to `null`, and SQLite's built-in statement atomicity handles the rest.
**Policy decision:** The sqlite-cr wrapper can be used, but ONLY for testing the Rust/C oracle (reference implementation), NEVER for testing the Zig extension.
141
+
142
+
**Audit results:** All 39 test scripts in `zig/harness/test-*.sh` are compliant:
143
+
- 38 scripts use clean `nix run nixpkgs#sqlite` + explicit `.load $ZIG_EXT`
144
+
- 1 script (`test-alter-parity.sh`) uses sqlite-cr correctly — only for Rust/C oracle
145
+
146
+
**AGENTS.md updated** with detailed Zig testing policy including:
147
+
- Core rule (no double-loading)
148
+
- sqlite-cr wrapper usage guidelines (ALLOWED vs FORBIDDEN)
- Analyzed Zig implementation: no explicit savepoint logic needed
49
+
50
+
## Completion Notes
51
+
52
+
**No implementation was needed.** SQLite's native statement/transaction semantics already provide the required atomicity guarantees for `crsql_changes` batch operations.
53
+
54
+
### Evidence
55
+
1.`changes_vtab.zig` lines 1997-2005 set `xBegin`, `xCommit`, `xRollback` to **null**
56
+
2. SQLite guarantees single-statement atomicity - a multi-row INSERT either fully commits or fully rolls back
57
+
3. All 8 atomicity tests pass:
58
+
- Test 1: Multi-row INSERT applies all rows atomically ✓
59
+
- Test 2: Invalid column in batch causes entire statement to fail ✓
60
+
- Test 3: rows_impacted resets to 0 after commit ✓
61
+
- Test 4: Failed transaction commits nothing ✓
62
+
- Test 5: Explicit savepoints allow partial rollback ✓
63
+
- Test 6: Duplicate PKs handled correctly (LWW) ✓
64
+
- Test 7: Base table integrity after failed batch ✓
65
+
- Test 8: rows_impacted accumulates within transaction ✓
66
+
67
+
### Why Rust uses explicit savepoints but Zig doesn't need them
68
+
The Rust implementation (`core/rs/core/src/changes_vtab_write.rs`) uses explicit savepoints for additional safety during complex merge operations. The Zig implementation relies on SQLite's native semantics which achieve the same effect for our use case because:
69
+
- Each INSERT INTO crsql_changes is a single statement
0 commit comments