Skip to content

Commit e09da62

Browse files
capture more tasks
1 parent af5196d commit e09da62

24 files changed

Lines changed: 938 additions & 13 deletions
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# TASK-161 — Test resurrection of live row via sentinel
2+
3+
## Goal
4+
Verify Zig matches Rust/C oracle when a sentinel (cid='-1') change is applied to an already-live row.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (cross-impl parity, CL semantics)
9+
10+
## Context
11+
From Python `test_cl_merging.py::test_resurrection_of_live_thing_via_sentinel`:
12+
- A row exists and is live
13+
- A sentinel change arrives with higher CL
14+
- Expected: row stays live, CL is updated
15+
16+
This tests the interaction between causal length and sentinel handling.
17+
18+
## Files to Modify
19+
- `zig/harness/test-resurrection-parity.sh` (new)
20+
21+
## Acceptance Criteria
22+
1. Test creates row on Site A
23+
2. Site B receives row via sync
24+
3. Site A deletes row (creates sentinel with CL=2)
25+
4. Site A re-inserts row (creates sentinel with CL=3)
26+
5. Meanwhile Site B still has live row (CL=1)
27+
6. Site B receives resurrection sentinel (CL=3)
28+
7. Verify: row is live on both, CL matches
29+
8. Zig and Rust/C oracle produce identical results
30+
31+
## Parent Docs / Cross-links
32+
- Python test: `py/correctness/test_cl_merging.py`
33+
- Related: TASK-162, TASK-163, TASK-164
34+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
35+
36+
## Progress Log
37+
- 2025-12-22: Created from gap analysis.
38+
39+
## Completion Notes
40+
(Empty until done.)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# TASK-162 — Test resurrection of deleted row via sentinel
2+
3+
## Goal
4+
Verify Zig matches Rust/C oracle when a sentinel resurrects a previously-deleted row.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (cross-impl parity, CL semantics)
9+
10+
## Context
11+
From Python `test_cl_merging.py::test_resurrection_of_dead_thing_via_sentinel`:
12+
- A row is deleted (tombstone exists)
13+
- A sentinel change arrives with higher CL
14+
- Expected: row is resurrected (tombstone cleared)
15+
16+
## Files to Modify
17+
- `zig/harness/test-resurrection-parity.sh` (new or extend)
18+
19+
## Acceptance Criteria
20+
1. Create row, then delete it (CL=2 tombstone)
21+
2. Sync tombstone to Site B
22+
3. Site A resurrects via INSERT (CL=3 sentinel)
23+
4. Sync resurrection to Site B
24+
5. Verify: row is live on both sites
25+
6. Verify: clock table shows CL=3
26+
7. Zig and Rust/C oracle produce identical results
27+
28+
## Parent Docs / Cross-links
29+
- Python test: `py/correctness/test_cl_merging.py`
30+
- Related: TASK-161, TASK-163, TASK-164
31+
32+
## Progress Log
33+
- 2025-12-22: Created from gap analysis.
34+
35+
## Completion Notes
36+
(Empty until done.)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# TASK-163 — Test resurrection of live row via column value
2+
3+
## Goal
4+
Verify Zig matches Rust/C oracle when a column update (not sentinel) arrives for an already-live row.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (cross-impl parity, CL semantics)
9+
10+
## Context
11+
From Python `test_cl_merging.py::test_resurrection_of_live_thing_via_non_sentinel`:
12+
- A row exists and is live
13+
- A column value change arrives with higher CL
14+
- Expected: column is updated, CL is updated
15+
16+
This is the normal UPDATE case but with explicit CL verification.
17+
18+
## Files to Modify
19+
- `zig/harness/test-resurrection-parity.sh` (new or extend)
20+
21+
## Acceptance Criteria
22+
1. Create row with col='original' on Site A
23+
2. Sync to Site B
24+
3. Site A updates col='updated' (col_version=2)
25+
4. Site B receives update
26+
5. Verify: both have col='updated'
27+
6. Verify: clock shows correct col_version and CL
28+
7. Zig and Rust/C oracle produce identical results
29+
30+
## Parent Docs / Cross-links
31+
- Python test: `py/correctness/test_cl_merging.py`
32+
- Related: TASK-161, TASK-162, TASK-164
33+
34+
## Progress Log
35+
- 2025-12-22: Created from gap analysis.
36+
37+
## Completion Notes
38+
(Empty until done.)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# TASK-163 — Test resurrection of deleted row via column value
2+
3+
## Goal
4+
Verify Zig matches Rust/C oracle when a column update resurrects a deleted row.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (cross-impl parity, CL semantics)
9+
10+
## Context
11+
From Python `test_cl_merging.py::test_resurrection_of_dead_thing_via_non_sentinel`:
12+
- A row was deleted (tombstone exists)
13+
- A column value change arrives with higher CL
14+
- Expected: row is resurrected with that column value
15+
16+
This is the tricky case where a column update must also resurrect.
17+
18+
## Files to Modify
19+
- `zig/harness/test-resurrection-parity.sh` (new or extend)
20+
21+
## Acceptance Criteria
22+
1. Create row, delete it (CL=2 tombstone)
23+
2. From a different site, send UPDATE with CL=3
24+
3. Verify: row is resurrected
25+
4. Verify: column has the new value
26+
5. Verify: clock shows CL=3
27+
6. Zig and Rust/C oracle produce identical results
28+
29+
## Parent Docs / Cross-links
30+
- Python test: `py/correctness/test_cl_merging.py`
31+
- Related: TASK-161, TASK-162, TASK-163
32+
33+
## Progress Log
34+
- 2025-12-22: Created from gap analysis.
35+
36+
## Completion Notes
37+
(Empty until done.)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# TASK-165 — Test out-of-order sync with delete/resurrect interleaving
2+
3+
## Goal
4+
Verify Zig handles out-of-order change arrival where deletes and resurrections interleave.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (cross-impl parity, production scenario)
9+
10+
## Context
11+
From Python `test_cl_merging.py::test_pr_299_scenario`:
12+
Real-world scenario where changes arrive out of order due to network delays.
13+
14+
Sequence:
15+
1. Site A: INSERT row
16+
2. Site A: DELETE row
17+
3. Site A: INSERT row (resurrect)
18+
4. Site B receives changes in order: 1, 3, 2 (delete arrives last)
19+
20+
Expected: Row should be live (resurrection has higher CL than delete).
21+
22+
## Files to Modify
23+
- `zig/harness/test-resurrection-parity.sh` (new or extend)
24+
25+
## Acceptance Criteria
26+
1. Simulate out-of-order arrival by manually ordering INSERT INTO crsql_changes
27+
2. Send: INSERT (CL=1), then RESURRECT (CL=3), then DELETE (CL=2)
28+
3. Verify: row is live (higher CL wins)
29+
4. Verify: idempotent (re-apply same changes, same result)
30+
5. Zig and Rust/C oracle produce identical results
31+
32+
## Parent Docs / Cross-links
33+
- Python test: `py/correctness/test_cl_merging.py`
34+
- GitHub PR: #299 scenario
35+
- Related: TASK-161 through TASK-164
36+
37+
## Progress Log
38+
- 2025-12-22: Created from gap analysis.
39+
40+
## Completion Notes
41+
(Empty until done.)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# TASK-166 — Test sentinel omission on INSERT
2+
3+
## Goal
4+
Verify Zig does NOT emit sentinel (cid='-1') on normal INSERT operations.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (wire format parity)
9+
10+
## Context
11+
From Python `test_sentinel_omission.py::test_omitted_on_insert`:
12+
- INSERT should create clock entries for each column
13+
- INSERT should NOT create a sentinel row (cid='-1')
14+
- Sentinel is only for delete/resurrect tracking
15+
16+
## Files to Modify
17+
- `zig/harness/test-sentinel-parity.sh` (new)
18+
19+
## Acceptance Criteria
20+
1. INSERT a row into CRR table
21+
2. Query crsql_changes
22+
3. Verify: changes exist for each column
23+
4. Verify: NO change with cid='-1' exists
24+
5. Zig and Rust/C oracle produce identical results
25+
26+
## Parent Docs / Cross-links
27+
- Python test: `py/correctness/test_sentinel_omission.py`
28+
- Related: TASK-167, TASK-168, TASK-169
29+
30+
## Progress Log
31+
- 2025-12-22: Created from gap analysis.
32+
33+
## Completion Notes
34+
(Empty until done.)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# TASK-167 — Test sentinel created on DELETE
2+
3+
## Goal
4+
Verify Zig creates sentinel (cid='-1') when a row is deleted.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (wire format parity)
9+
10+
## Context
11+
From Python `test_sentinel_omission.py::test_created_on_delete`:
12+
- DELETE should create a sentinel row (cid='-1') in clock table
13+
- This sentinel marks the row as tombstoned
14+
- The sentinel has a CL value for resurrection comparison
15+
16+
## Files to Modify
17+
- `zig/harness/test-sentinel-parity.sh` (new or extend)
18+
19+
## Acceptance Criteria
20+
1. INSERT a row into CRR table
21+
2. DELETE the row
22+
3. Query crsql_changes
23+
4. Verify: sentinel change with cid='-1' exists
24+
5. Verify: sentinel has correct CL (should be 2)
25+
6. Zig and Rust/C oracle produce identical results
26+
27+
## Parent Docs / Cross-links
28+
- Python test: `py/correctness/test_sentinel_omission.py`
29+
- Related: TASK-166, TASK-168, TASK-169
30+
31+
## Progress Log
32+
- 2025-12-22: Created from gap analysis.
33+
34+
## Completion Notes
35+
(Empty until done.)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# TASK-168 — Test sentinel NOT created on INSERT OR REPLACE
2+
3+
## Goal
4+
Verify Zig does NOT create sentinel on INSERT OR REPLACE.
5+
6+
## Status
7+
- State: triage
8+
- Priority: medium (edge case)
9+
10+
## Context
11+
From Python `test_sentinel_omission.py::test_not_created_on_replace`:
12+
- INSERT OR REPLACE is logically an UPDATE (or INSERT if new)
13+
- It should NOT create a sentinel
14+
- Only explicit DELETE creates sentinel
15+
16+
## Files to Modify
17+
- `zig/harness/test-sentinel-parity.sh` (new or extend)
18+
19+
## Acceptance Criteria
20+
1. INSERT a row
21+
2. INSERT OR REPLACE same PK with different values
22+
3. Query crsql_changes
23+
4. Verify: column changes exist
24+
5. Verify: NO sentinel (cid='-1') exists
25+
6. Zig and Rust/C oracle produce identical results
26+
27+
## Parent Docs / Cross-links
28+
- Python test: `py/correctness/test_sentinel_omission.py`
29+
- Related: TASK-166, TASK-167, TASK-169
30+
31+
## Progress Log
32+
- 2025-12-22: Created from gap analysis.
33+
34+
## Completion Notes
35+
(Empty until done.)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# TASK-169 — Test sentinel NOT created during merge (sync)
2+
3+
## Goal
4+
Verify Zig does NOT create new sentinel when applying remote changes.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (sync correctness)
9+
10+
## Context
11+
From Python `test_sentinel_omission.py::test_not_created_on_merge`:
12+
- When applying changes via INSERT INTO crsql_changes
13+
- We should NOT create NEW sentinels
14+
- We should only propagate existing sentinels
15+
16+
Creating sentinels during merge would corrupt CL tracking.
17+
18+
## Files to Modify
19+
- `zig/harness/test-sentinel-parity.sh` (new or extend)
20+
21+
## Acceptance Criteria
22+
1. Site A: INSERT row
23+
2. Sync to Site B via crsql_changes
24+
3. Verify: Site B has row but NO sentinel in its clock
25+
4. Site A: DELETE row (creates sentinel CL=2)
26+
5. Sync delete to Site B
27+
6. Verify: Site B has sentinel with CL=2 (propagated, not new)
28+
7. Zig and Rust/C oracle produce identical results
29+
30+
## Parent Docs / Cross-links
31+
- Python test: `py/correctness/test_sentinel_omission.py`
32+
- Related: TASK-166, TASK-167, TASK-168
33+
34+
## Progress Log
35+
- 2025-12-22: Created from gap analysis.
36+
37+
## Completion Notes
38+
(Empty until done.)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# TASK-170 — Test foreign keys between CRR tables
2+
3+
## Goal
4+
Verify Zig handles foreign key constraints between CRR tables correctly during sync.
5+
6+
## Status
7+
- State: triage
8+
- Priority: high (real-world apps have FKs)
9+
10+
## Context
11+
No existing tests verify FK behavior between CRR tables. Real apps commonly have:
12+
- Parent/child relationships (orders → line_items)
13+
- Many-to-many via junction tables
14+
- Self-referential FKs (org hierarchy)
15+
16+
Key questions:
17+
1. What happens when child row arrives before parent?
18+
2. Does FK violation during merge fail or defer?
19+
3. Are FK constraints even compatible with CRRs?
20+
21+
## Files to Modify
22+
- `zig/harness/test-fk-crr.sh` (new)
23+
24+
## Acceptance Criteria
25+
1. Create parent CRR table with PK
26+
2. Create child CRR table with FK to parent
27+
3. Insert parent, then child — works
28+
4. Sync child to Site B (parent not yet synced)
29+
5. Document behavior (fail? deferred? ignored?)
30+
6. Sync parent to Site B
31+
7. Verify FK constraint now satisfied
32+
8. Zig and Rust/C oracle produce identical results (or document difference)
33+
34+
## Parent Docs / Cross-links
35+
- Related: TASK-171 (cascading deletes)
36+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
37+
38+
## Progress Log
39+
- 2025-12-22: Created from gap analysis.
40+
41+
## Completion Notes
42+
(Empty until done.)

0 commit comments

Comments
 (0)