|
| 1 | +# TASK-089: Oracle Parity — API surface completeness |
| 2 | + |
| 3 | +## Status |
| 4 | +- [ ] Planned |
| 5 | +- [ ] Assigned |
| 6 | +- [ ] In Progress |
| 7 | +- [ ] Blocked (reason: ...) |
| 8 | +- [x] Complete |
| 9 | + |
| 10 | +## Priority |
| 11 | +high |
| 12 | + |
| 13 | +## Assigned To |
| 14 | +Claude (completed 2025-12-17) |
| 15 | + |
| 16 | +## Parent Docs / Cross-links |
| 17 | +- Rust extension entry: `core/rs/core/src/lib.rs` |
| 18 | +- Zig extension entry: `zig/src/crsqlite.zig` |
| 19 | +- Gap backlog: `research/zig-cr/92-gap-backlog.md` |
| 20 | + |
| 21 | +## Description |
| 22 | +Verify that Zig exposes the same SQL API surface as Rust/C. Use `pragma_function_list` and `pragma_module_list` to enumerate all registered functions and virtual table modules, then compare. |
| 23 | + |
| 24 | +This is an **oracle test**: Rust/C is the golden master. Any function or module present in Rust/C but missing from Zig is a gap. |
| 25 | + |
| 26 | +## Files to Modify |
| 27 | +- `zig/harness/test-api-surface.sh` (new) |
| 28 | +- `zig/harness/test-parity.sh` (wire into suite) |
| 29 | +- `research/zig-cr/92-gap-backlog.md` |
| 30 | + |
| 31 | +## Acceptance Criteria |
| 32 | +- [x] Test extracts function list from Rust/C extension: `SELECT name FROM pragma_function_list WHERE name LIKE 'crsql%' ORDER BY name` |
| 33 | +- [x] Test extracts function list from Zig extension using same query. |
| 34 | +- [x] Test extracts module list from both: `SELECT name FROM pragma_module_list WHERE name LIKE 'crsql%' OR name = 'clset' ORDER BY name` |
| 35 | +- [x] Test fails if Rust/C has functions/modules not present in Zig. |
| 36 | +- [x] Test documents which functions are intentionally excluded (if any) with rationale. |
| 37 | +- [x] Functions to verify include (at minimum): |
| 38 | + - `crsql_as_crr`, `crsql_as_table` ✓ (both present in Zig) |
| 39 | + - `crsql_begin_alter`, `crsql_commit_alter` ✓ (both present in Zig) |
| 40 | + - `crsql_changes`, `crsql_tracked_peers` ✓ (crsql_changes present; crsql_tracked_peers not in Rust/C either - it's a different concept) |
| 41 | + - `crsql_db_version`, `crsql_next_db_version` ✓ (both present in Zig) |
| 42 | + - `crsql_site_id`, `crsql_siteid` (alias) ✓ (crsql_site_id present; alias not found in Rust/C pragma_function_list) |
| 43 | + - `crsql_finalize` ✓ (present in Zig) |
| 44 | + - `crsql_fract_key_between` ✓ (present in Zig) |
| 45 | + - `crsql_pack_columns`, `crsql_rows_impacted` ✓ (both present in Zig) |
| 46 | + - `crsql_automigrate` (if implemented) ✗ MISSING - in Rust/C, not in Zig |
| 47 | + - `crsql_config_get`, `crsql_config_set` (if implemented) ✗ MISSING - in Rust/C, not in Zig |
| 48 | + |
| 49 | +## Progress Log |
| 50 | +### 2025-12-18 |
| 51 | +- Task created from oracle-based parity test suite. |
| 52 | + |
| 53 | +### 2025-12-17 (execution) |
| 54 | +- Created `zig/harness/test-api-surface.sh` - oracle parity test comparing Rust/C vs Zig |
| 55 | +- Wired into `zig/harness/test-parity.sh` |
| 56 | +- Ran `bash zig/harness/test-parity.sh` - API surface test integrated successfully |
| 57 | +- Documented all gaps discovered |
| 58 | + |
| 59 | +## Commands Run |
| 60 | +```bash |
| 61 | +# Standalone API surface test |
| 62 | +bash /Users/tom/Developer/effect-native/cr-sqlite/zig/harness/test-api-surface.sh |
| 63 | + |
| 64 | +# Full parity suite |
| 65 | +bash /Users/tom/Developer/effect-native/cr-sqlite/zig/harness/test-parity.sh |
| 66 | +``` |
| 67 | + |
| 68 | +## Full Test Output |
| 69 | +``` |
| 70 | +╔═══════════════════════════════════════════════════════════════════════╗ |
| 71 | +║ API Surface Parity Test (Oracle: Rust/C) ║ |
| 72 | +╚═══════════════════════════════════════════════════════════════════════╝ |
| 73 | +
|
| 74 | +Rust/C extension: /Users/tom/Developer/effect-native/cr-sqlite/lib/crsqlite.dylib |
| 75 | +Zig extension: /Users/tom/Developer/effect-native/cr-sqlite/lib/crsqlite-zig-darwin-aarch64.dylib |
| 76 | +
|
| 77 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 78 | +Extracting function lists... |
| 79 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 80 | +
|
| 81 | +Rust/C functions (23): |
| 82 | + crsql_after_delete |
| 83 | + crsql_after_insert |
| 84 | + crsql_after_update |
| 85 | + crsql_as_crr |
| 86 | + crsql_as_table |
| 87 | + crsql_automigrate |
| 88 | + crsql_begin_alter |
| 89 | + crsql_commit_alter |
| 90 | + crsql_config_get |
| 91 | + crsql_config_set |
| 92 | + crsql_db_version |
| 93 | + crsql_finalize |
| 94 | + crsql_fract_as_ordered |
| 95 | + crsql_fract_fix_conflict_return_old_key |
| 96 | + crsql_fract_key_between |
| 97 | + crsql_get_seq |
| 98 | + crsql_increment_and_get_seq |
| 99 | + crsql_internal_sync_bit |
| 100 | + crsql_next_db_version |
| 101 | + crsql_pack_columns |
| 102 | + crsql_rows_impacted |
| 103 | + crsql_sha |
| 104 | + crsql_site_id |
| 105 | +
|
| 106 | +Zig functions (18): |
| 107 | + crsql_as_crr |
| 108 | + crsql_as_table |
| 109 | + crsql_begin_alter |
| 110 | + crsql_commit_alter |
| 111 | + crsql_db_version |
| 112 | + crsql_finalize |
| 113 | + crsql_fract_as_ordered |
| 114 | + crsql_fract_fix_conflict_return_old_key |
| 115 | + crsql_fract_key_between |
| 116 | + crsql_increment_and_get_seq |
| 117 | + crsql_internal_sync_bit |
| 118 | + crsql_is_crr |
| 119 | + crsql_next_db_version |
| 120 | + crsql_pack_columns |
| 121 | + crsql_rows_impacted |
| 122 | + crsql_site_id |
| 123 | + crsql_version |
| 124 | + crsql_zig_version |
| 125 | +
|
| 126 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 127 | +Extracting module lists... |
| 128 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 129 | +
|
| 130 | +Rust/C modules (3): |
| 131 | + clset |
| 132 | + crsql_changes |
| 133 | + crsql_unpack_columns |
| 134 | +
|
| 135 | +Zig modules (1): |
| 136 | + crsql_changes |
| 137 | +
|
| 138 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 139 | +Comparing API surfaces... |
| 140 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 141 | +
|
| 142 | +FAIL: 8 functions in Rust/C but missing from Zig: |
| 143 | + - crsql_after_delete |
| 144 | + - crsql_after_insert |
| 145 | + - crsql_after_update |
| 146 | + - crsql_automigrate |
| 147 | + - crsql_config_get |
| 148 | + - crsql_config_set |
| 149 | + - crsql_get_seq |
| 150 | + - crsql_sha |
| 151 | +
|
| 152 | +INFO: 3 functions in Zig but not in Rust/C (Zig-specific): |
| 153 | + + crsql_is_crr |
| 154 | + + crsql_version |
| 155 | + + crsql_zig_version |
| 156 | +
|
| 157 | +FAIL: 2 modules in Rust/C but missing from Zig: |
| 158 | + - clset |
| 159 | + - crsql_unpack_columns |
| 160 | +
|
| 161 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 162 | +Intentional Exclusions (documented rationale): |
| 163 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 164 | +
|
| 165 | + crsql_after_delete, crsql_after_insert, crsql_after_update: |
| 166 | + Internal trigger functions - not part of public API. |
| 167 | + These are registered for use by auto-generated triggers only. |
| 168 | +
|
| 169 | + crsql_sha: |
| 170 | + Debug/utility function - not essential for CRDT operations. |
| 171 | +
|
| 172 | + crsql_siteid (alias): |
| 173 | + Legacy alias - crsql_site_id is the canonical function. |
| 174 | +
|
| 175 | +
|
| 176 | +╔═══════════════════════════════════════════════════════════════════════╗ |
| 177 | +║ API SURFACE SUMMARY ║ |
| 178 | +╠═══════════════════════════════════════════════════════════════════════╣ |
| 179 | +║ Rust/C Functions: 23 ║ |
| 180 | +║ Zig Functions: 18 ║ |
| 181 | +║ Rust/C Modules: 3 ║ |
| 182 | +║ Zig Modules: 1 ║ |
| 183 | +╠═══════════════════════════════════════════════════════════════════════╣ |
| 184 | +║ Missing from Zig: 10 ║ |
| 185 | +╚═══════════════════════════════════════════════════════════════════════╝ |
| 186 | +
|
| 187 | +✗ API surface parity: FAIL (10 gaps found) |
| 188 | +``` |
| 189 | + |
| 190 | +## Gaps Discovered |
| 191 | + |
| 192 | +### Functions Missing from Zig (require implementation) |
| 193 | +| Function | Priority | Notes | |
| 194 | +|----------|----------|-------| |
| 195 | +| `crsql_automigrate` | Medium | Schema migration support | |
| 196 | +| `crsql_config_get` | Medium | Configuration API | |
| 197 | +| `crsql_config_set` | Medium | Configuration API | |
| 198 | +| `crsql_get_seq` | Low | Sequence getter (crsql_increment_and_get_seq exists) | |
| 199 | + |
| 200 | +### Functions Intentionally Excluded (internal/debug) |
| 201 | +| Function | Rationale | |
| 202 | +|----------|-----------| |
| 203 | +| `crsql_after_delete` | Internal trigger function | |
| 204 | +| `crsql_after_insert` | Internal trigger function | |
| 205 | +| `crsql_after_update` | Internal trigger function | |
| 206 | +| `crsql_sha` | Debug/utility function | |
| 207 | + |
| 208 | +### Modules Missing from Zig |
| 209 | +| Module | Priority | Notes | |
| 210 | +|--------|----------|-------| |
| 211 | +| `clset` | Medium | Changeset virtual table | |
| 212 | +| `crsql_unpack_columns` | Low | Column unpacking vtab | |
| 213 | + |
| 214 | +### Zig-Specific Additions (not in Rust/C) |
| 215 | +| Function | Notes | |
| 216 | +|----------|-------| |
| 217 | +| `crsql_is_crr` | Utility to check if table is a CRR | |
| 218 | +| `crsql_version` | Version string | |
| 219 | +| `crsql_zig_version` | Zig implementation version | |
| 220 | + |
| 221 | +## Completion Notes |
| 222 | +Task completed. Created `zig/harness/test-api-surface.sh` that: |
| 223 | +1. Loads both extensions into clean sqlite3 processes |
| 224 | +2. Extracts function and module lists via pragma queries |
| 225 | +3. Compares using `comm` to find gaps |
| 226 | +4. Reports missing items with clear categorization |
| 227 | +5. Documents intentional exclusions with rationale |
| 228 | + |
| 229 | +The test is wired into `test-parity.sh` and runs as part of `make -C zig test-parity`. |
| 230 | + |
| 231 | +**10 total gaps identified** (8 functions + 2 modules), of which 4 functions are intentionally excluded (internal trigger functions + debug utility). |
0 commit comments