Skip to content

Commit c3001fb

Browse files
Round 64: discover 3 new gaps, organize triage inbox
- TASK-188: crsql_get_seq() function missing - TASK-189: crsql_tracked_peers table missing - TASK-181: confirmed crsql_sha() function missing - Gap backlog updated with prioritized triage table (11 items)
1 parent 66524a1 commit c3001fb

File tree

4 files changed

+186
-16
lines changed

4 files changed

+186
-16
lines changed

.tasks/triage/TASK-181-crsql-sha-function.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ Add crsql_sha() function that returns git commit SHA (for version tracing).
66
## Status
77
- State: triage
88
- Priority: low (debug/version info only)
9+
- Confirmed: Round 64 — verified missing via function list comparison
10+
11+
## Problem
12+
```sql
13+
-- Rust/C oracle:
14+
SELECT crsql_sha(); -- Returns '0d62b52b4662ee1a762c9fd9264d48a91ab8df83'
15+
16+
-- Zig:
17+
SELECT crsql_sha(); -- ERROR: no such function
18+
```
919

1020
## Context
1121
Rust/C has `crsql_sha()` that returns the git commit hash of the build.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# TASK-188 — Implement crsql_get_seq() function
2+
3+
## Goal
4+
Add crsql_get_seq() function that returns current seq value without incrementing.
5+
6+
## Status
7+
- State: triage
8+
- Priority: medium (API completeness)
9+
- Discovered: Round 64 update tasks
10+
11+
## Problem
12+
Rust/C has `crsql_get_seq()` function but Zig doesn't:
13+
```sql
14+
-- Rust/C oracle:
15+
SELECT crsql_get_seq(); -- Returns 0 (or current seq)
16+
17+
-- Zig:
18+
SELECT crsql_get_seq(); -- ERROR: no such function
19+
```
20+
21+
## Context
22+
- `crsql_increment_and_get_seq()` exists in both implementations
23+
- `crsql_get_seq()` is a read-only version that doesn't increment
24+
- Used by sync clients to get current seq without side effects
25+
26+
## Files to Modify
27+
- `zig/src/db_version.zig` (or `seq.zig` if exists) — add function
28+
- `zig/src/ffi/init.zig` — register function
29+
30+
## Acceptance Criteria
31+
1. `SELECT crsql_get_seq()` returns current seq value
32+
2. Calling it multiple times returns same value (no increment)
33+
3. Value matches `crsql_increment_and_get_seq()` before any increment
34+
4. Zig matches Rust/C oracle behavior
35+
36+
## Parent Docs / Cross-links
37+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
38+
- Related: TASK-181 (crsql_sha — also missing function)
39+
40+
## Progress Log
41+
- 2025-12-22: Created from gap analysis.
42+
43+
## Completion Notes
44+
(Empty until done.)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# TASK-189 — Create crsql_tracked_peers table
2+
3+
## Goal
4+
Create the crsql_tracked_peers table that Rust/C creates on initialization.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (sync infrastructure)
9+
- Discovered: Round 64 update tasks
10+
11+
## Problem
12+
Rust/C creates a `crsql_tracked_peers` table on init, Zig doesn't:
13+
```sql
14+
-- Rust/C oracle:
15+
.tables
16+
-- crsql_master crsql_site_id crsql_tracked_peers
17+
18+
-- Zig:
19+
.tables
20+
-- crsql_master crsql_site_id
21+
```
22+
23+
## Context
24+
This table is used for tracking peer sync state. Schema from bootstrap.rs:
25+
```sql
26+
CREATE TABLE IF NOT EXISTS crsql_tracked_peers (
27+
"site_id" BLOB NOT NULL,
28+
"version" INTEGER NOT NULL,
29+
"seq" INTEGER DEFAULT 0,
30+
"tag" INTEGER,
31+
"event" INTEGER,
32+
PRIMARY KEY ("site_id", "tag", "event")
33+
) STRICT;
34+
```
35+
36+
Purpose:
37+
- Track which version/seq has been synced to/from each peer
38+
- Allows resumable sync (don't re-send already-synced changes)
39+
- Used by sync clients to maintain sync cursors
40+
41+
## Files to Modify
42+
- `zig/src/ffi/init.zig` — add table creation in `initModule()`
43+
- `zig/harness/test-tracked-peers.sh` (new) — test the table
44+
45+
## Acceptance Criteria
46+
1. Table `crsql_tracked_peers` exists after extension loads
47+
2. Schema matches Rust/C oracle exactly
48+
3. Table is STRICT
49+
4. Primary key constraint works
50+
5. Can INSERT/UPDATE/DELETE rows
51+
6. Table survives db close/reopen
52+
53+
## Parent Docs / Cross-links
54+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
55+
- Rust impl: `core/rs/core/src/bootstrap.rs:52`
56+
57+
## Progress Log
58+
- 2025-12-22: Created from gap analysis.
59+
60+
## Completion Notes
61+
(Empty until done.)

research/zig-cr/92-gap-backlog.md

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 92-gap-backlog
22

3-
> Last updated: 2025-12-22 (Round 63: Fixed 3 critical divergences)
3+
> Last updated: 2025-12-22 (Round 64: Gap discovery and triage organization)
44
55
## Status
66

@@ -14,26 +14,81 @@
1414
- Resurrection parity: ✅ **25/25 PASSING** (Round 63)
1515
- Sentinel parity: ✅ **6/6 PASSING** (Round 63)
1616
- Multinode sync: ✅ **6/6 PASSING** (Round 63)
17+
- Schema mismatch: ⚠️ **11/12 PASSING** (1 divergence: unknown column behavior)
18+
- Test scripts: **57 total**
1719
- Zig implementation: `zig/`
1820
- Canonical task queue: `.tasks/{backlog,active,done}/`
1921

2022
## Now (next parallel assignments)
2123

22-
**Backlog is empty** — Round 62 test suites completed, Round 63 divergence fixes completed.
23-
24-
### Triage Inbox (lower priority, not blocking)
25-
26-
| Task | Summary | Priority |
27-
|------|---------|----------|
28-
| TASK-156 | Linux CI parity | Low |
29-
| TASK-175 | Savepoints during sync | Medium |
30-
| TASK-176 | ATTACH database with CRRs | Medium |
31-
| TASK-178 | VACUUM on CRR database | Low |
32-
| TASK-180 | Site ID collision | Medium |
33-
| TASK-181 | crsql_sha() function | Low |
34-
| TASK-182 | User triggers modify other CRRs | Medium |
35-
| TASK-183 | Wide table performance | Low |
36-
| TASK-186 | Schema mismatch: unknown column behavior | Medium (design decision) |
24+
**Backlog is empty** — Triage contains 11 items ready for prioritization.
25+
26+
### Triage Inbox (organized by priority)
27+
28+
#### HIGH Priority — Missing Core Features
29+
| Task | Summary | Risk | Effort |
30+
|------|---------|------|--------|
31+
| **TASK-189** | crsql_tracked_peers table missing | Sync clients need this for cursors | Low |
32+
| **TASK-188** | crsql_get_seq() function missing | API completeness | Low |
33+
34+
#### MEDIUM Priority — Behavioral Parity
35+
| Task | Summary | Risk | Effort |
36+
|------|---------|------|--------|
37+
| **TASK-186** | Schema mismatch: unknown column behavior | Design decision | Low |
38+
| **TASK-175** | Savepoints during sync | Transaction correctness | Medium |
39+
| **TASK-176** | ATTACH database with CRRs | Multi-db patterns | Medium |
40+
| **TASK-180** | Site ID collision handling | Security edge case | Medium |
41+
| **TASK-182** | User triggers modify other CRRs | Real-world pattern | Medium |
42+
43+
#### LOW Priority — Nice to Have
44+
| Task | Summary | Risk | Effort |
45+
|------|---------|------|--------|
46+
| **TASK-181** | crsql_sha() function | Debug only | Low |
47+
| **TASK-178** | VACUUM on CRR database | Maintenance op | Low |
48+
| **TASK-183** | Wide table (50+ cols) performance | Performance only | Medium |
49+
| **TASK-156** | Linux CI parity | CI only | Medium |
50+
51+
### Function Comparison (Round 64 Discovery)
52+
53+
**Rust/C Functions (22 total):**
54+
```
55+
crsql_after_delete, crsql_after_insert, crsql_after_update
56+
crsql_as_crr, crsql_as_table, crsql_automigrate
57+
crsql_begin_alter, crsql_commit_alter
58+
crsql_config_get, crsql_config_set
59+
crsql_db_version, crsql_finalize
60+
crsql_fract_as_ordered, crsql_fract_fix_conflict_return_old_key, crsql_fract_key_between
61+
crsql_get_seq, crsql_increment_and_get_seq
62+
crsql_internal_sync_bit, crsql_next_db_version
63+
crsql_pack_columns, crsql_rows_impacted
64+
crsql_sha, crsql_site_id
65+
```
66+
67+
**Zig Functions (24 total):**
68+
```
69+
crsql_after_delete, crsql_after_insert, crsql_after_update
70+
crsql_as_crr, crsql_as_table, crsql_automigrate (x2)
71+
crsql_begin_alter (x2), crsql_commit_alter (x2)
72+
crsql_config_get, crsql_config_set
73+
crsql_db_version, crsql_finalize
74+
crsql_fract_as_ordered, crsql_fract_fix_conflict_return_old_key, crsql_fract_key_between
75+
crsql_increment_and_get_seq
76+
crsql_internal_sync_bit, crsql_is_crr, crsql_next_db_version
77+
crsql_pack_columns, crsql_rows_impacted
78+
crsql_site_id, crsql_version, crsql_zig_version
79+
```
80+
81+
**Missing from Zig:**
82+
- `crsql_get_seq` — TASK-188
83+
- `crsql_sha` — TASK-181
84+
85+
**Extra in Zig (OK):**
86+
- `crsql_is_crr` — useful debug function
87+
- `crsql_version`, `crsql_zig_version` — version info
88+
89+
**Table Comparison:**
90+
- Rust/C: `crsql_master`, `crsql_site_id`, `crsql_tracked_peers`
91+
- Zig: `crsql_master`, `crsql_site_id`**missing `crsql_tracked_peers`**
3792

3893
**Completed Round 63 (2025-12-22):**
3994
- [x] TASK-184: Fix resurrection via sentinel (tombstoned rows now resurrect) ✓

0 commit comments

Comments
 (0)