|
| 1 | +# TASK-143 — Cross-open modification compatibility (trigger schema interoperability) |
| 2 | + |
| 3 | +## Goal |
| 4 | +Enable a database created by one CR-SQLite implementation (Zig vs Rust/C) to be **modified** by the other implementation without errors, and with correct change tracking. |
| 5 | + |
| 6 | +This gap is currently explicitly marked as "known limitation" in `zig/harness/test-cross-open-parity.sh` (XO-003, XO-004, XO-006). |
| 7 | + |
| 8 | +## Status |
| 9 | +- State: triage |
| 10 | +- Priority: high |
| 11 | + |
| 12 | +## Problem Statement |
| 13 | +Cross-open **read-only** works, but cross-open **modification** fails due to trigger schema incompatibility. |
| 14 | + |
| 15 | +Evidence: |
| 16 | +- `bash zig/harness/test-cross-open-parity.sh` reports: |
| 17 | + - 17 passed |
| 18 | + - 0 failed |
| 19 | + - 3 known-fail |
| 20 | +- Known-fail tests: |
| 21 | + - XO-003: Zig creates → Rust modifies → Zig reads |
| 22 | + - XO-004: Rust creates → Zig modifies → Rust reads |
| 23 | + - XO-006: alternating modification between implementations |
| 24 | + |
| 25 | +Root cause (as described in `zig/harness/test-cross-open-parity.sh`): |
| 26 | +- Zig triggers embed `crsql_pack_columns()` directly in SQL. |
| 27 | +- Rust/C triggers call helper functions `crsql_after_insert/update/delete()`. |
| 28 | + |
| 29 | +When an implementation opens a DB created by the other and attempts INSERT/UPDATE/DELETE, the triggers call functions that are missing / rejected: |
| 30 | +- Rust on Zig DB: "unsafe use of crsql_pack_columns" (or equivalent failure) |
| 31 | +- Zig on Rust DB: "no such function: crsql_after_*" |
| 32 | + |
| 33 | +## Files to Modify |
| 34 | +(Exact scope to confirm during implementation planning; keep tight.) |
| 35 | +- `zig/harness/test-cross-open-parity.sh` (convert known-fail → real assertions once fixed) |
| 36 | +- One of: |
| 37 | + - `zig/src/as_crr.zig` |
| 38 | + - `zig/src/ffi/init.zig` |
| 39 | + - `zig/src/*.zig` trigger helper wiring (as needed) |
| 40 | +- Potentially (if required): `core/src/*.c` trigger schema / init (only if we decide to unify the schema on the Rust/C side) |
| 41 | + |
| 42 | +## Acceptance Criteria |
| 43 | +1. `bash zig/harness/test-cross-open-parity.sh` reports: |
| 44 | + - XO-003 PASS |
| 45 | + - XO-004 PASS |
| 46 | + - XO-006 PASS |
| 47 | + - `KNOWN_FAIL: 0` |
| 48 | +2. Cross-implementation modification succeeds without relying on sqlite-cr wrapper (must follow `AGENTS.md` rule: Zig tested via clean `nix run nixpkgs#sqlite` + explicit `.load $ZIG_EXT`). |
| 49 | +3. Modifications performed by the "other" implementation are correctly reflected in: |
| 50 | + - base table data |
| 51 | + - `crsql_db_version()` |
| 52 | + - `__crsql_clock` / `crsql_changes` outputs, as asserted by the harness |
| 53 | + |
| 54 | +## Parent Docs / Cross-links |
| 55 | +- `zig/harness/test-cross-open-parity.sh` (XO-003/004/006 known limitation) |
| 56 | +- `AGENTS.md` (Zig testing policy; sqlite-cr wrapper restrictions) |
| 57 | + |
| 58 | +## Progress Log |
| 59 | +- 2025-12-21: Created task from known-fail cross-open modification tests. |
| 60 | + |
| 61 | +## Completion Notes |
| 62 | +(Empty until done.) |
0 commit comments