Skip to content

Commit 10b480c

Browse files
++
1 parent b69fe0b commit 10b480c

File tree

6 files changed

+280
-144
lines changed

6 files changed

+280
-144
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# TASK-070: Zig parity — Cover missing C suites (ext-data + sandbox)
2+
3+
## Status
4+
- [ ] Planned
5+
- [ ] Assigned
6+
- [ ] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [ ] Complete
9+
10+
## Priority
11+
high
12+
13+
## Assigned To
14+
(unassigned)
15+
16+
## Parent Docs / Cross-links
17+
- C test runner: `core/src/tests.c`
18+
- Missing suites:
19+
- `core/src/ext-data.test.c`
20+
- `core/src/sandbox.test.c`
21+
- Zig parity runner: `zig/harness/test-parity.sh`
22+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
23+
24+
## Description
25+
The Zig parity harness currently focuses on the `rows-impacted`, `changes-vtab`, rowid slab, alter, noop, and fract behaviors.
26+
27+
To invalidate the hypothesis that the Zig port is "done", we need parity coverage for the remaining C-level suites that exercise real-world failure modes:
28+
29+
- **ext-data**: per-connection extension data lifecycle and correctness under multiple connections.
30+
- **sandbox**: safety rails / invariants the extension expects from SQLite (and that users will hit in production).
31+
32+
This task adds parity scripts for these suites (or ports their assertions into `zig/harness/test-parity.sh`) so Zig behavior is continuously compared against the C/Rust reference.
33+
34+
## Files to Modify
35+
- `zig/harness/test-parity.sh`
36+
- `zig/harness/test-ext-data.sh` (new)
37+
- `zig/harness/test-sandbox.sh` (new)
38+
- `research/zig-cr/92-gap-backlog.md`
39+
40+
## Acceptance Criteria
41+
- [ ] `zig/harness/test-parity.sh` runs ext-data + sandbox coverage (no silent gaps).
42+
- [ ] `make -C zig test-parity` passes locally.
43+
- [ ] Failures (if found) are turned into follow-up tasks with tight `Files to Modify`.
44+
- [ ] Evidence captured in this card:
45+
- commands run
46+
- pasted failing output (if any)
47+
48+
## Progress Log
49+
### 2025-12-18
50+
- Task created during "update tasks" to invalidate "zig is done".
51+
52+
## Completion Notes
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# TASK-071: Zig parity — Cover remaining C suites (crsqlite + is-crr)
2+
3+
## Status
4+
- [ ] Planned
5+
- [ ] Assigned
6+
- [ ] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [ ] Complete
9+
10+
## Priority
11+
high
12+
13+
## Assigned To
14+
(unassigned)
15+
16+
## Parent Docs / Cross-links
17+
- C test runner: `core/src/tests.c`
18+
- Suites to cover:
19+
- `core/src/crsqlite.test.c`
20+
- `core/src/is-crr.test.c`
21+
- Zig parity runner: `zig/harness/test-parity.sh`
22+
- Existing Zig harness scripts: `zig/harness/test-is-crr.sh`
23+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
24+
25+
## Description
26+
The C reference test runner (`core/src/tests.c`) includes suites for base extension behaviors (`crsqlite`) and CRR detection (`is-crr`).
27+
28+
Some of this may already be covered by existing Zig harness scripts, but the parity runner must make this explicit and non-optional.
29+
30+
This task ensures:
31+
- We have Zig-side tests that correspond to the C suite assertions.
32+
- `zig/harness/test-parity.sh` actually runs them (so we’re not "green" due to missing coverage).
33+
34+
## Files to Modify
35+
- `zig/harness/test-parity.sh`
36+
- `zig/harness/test-crsqlite.sh` (new, if needed)
37+
- `zig/harness/test-is-crr.sh` (if wiring/assertions need adjustments)
38+
- `research/zig-cr/92-gap-backlog.md`
39+
40+
## Acceptance Criteria
41+
- [ ] `make -C zig test-parity` exercises `crsqlite` and `is_crr` equivalently to the C runner.
42+
- [ ] No parity suite remains uncovered from the set in `core/src/*.test.c`.
43+
- [ ] Evidence captured in this card: commands + outputs.
44+
45+
## Progress Log
46+
### 2025-12-18
47+
- Task created during "update tasks" to invalidate "zig is done".
48+
49+
## Completion Notes
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# TASK-072: Zig correctness — Make `crsql_internal_sync_bit` per-connection
2+
3+
## Status
4+
- [ ] Planned
5+
- [ ] Assigned
6+
- [ ] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [ ] Complete
9+
10+
## Priority
11+
high
12+
13+
## Assigned To
14+
(unassigned)
15+
16+
## Parent Docs / Cross-links
17+
- Rust integration test that implies behavior: `core/rs/integration_check/src/t/sync_bit_honored.rs`
18+
- Zig implementation: `zig/src/sync_bit.zig`
19+
- Zig trigger gating references:
20+
- `zig/src/as_crr.zig`
21+
- `zig/src/schema_alter.zig`
22+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
23+
24+
## Description
25+
Real systems will have multiple SQLite connections in-process (connection pools, background writers, migrations, etc.).
26+
27+
`crsql_internal_sync_bit()` is used to gate triggers during merges. If this bit is global (process-wide) instead of per-connection, then one connection performing a merge can accidentally suppress change-capture in another connection.
28+
29+
The current Zig implementation uses a global `sync_bit` variable, which is a high-risk correctness bug that existing tests do not explicitly invalidate.
30+
31+
This task:
32+
1. Defines and tests the required per-connection behavior.
33+
2. Refactors the Zig implementation so the sync-bit state is stored per SQLite connection (likely in extension data associated with `sqlite3*`).
34+
35+
## Files to Modify
36+
- `zig/src/sync_bit.zig`
37+
- `zig/src/ffi/init.zig` (if UDF needs per-conn context wiring)
38+
- `zig/harness/test-sync-bit-isolation.sh` (new)
39+
- `zig/src/**` (only if needed for ext-data plumbing)
40+
- `research/zig-cr/92-gap-backlog.md`
41+
42+
## Acceptance Criteria
43+
- [ ] New test reproduces the multi-connection hazard:
44+
- Connection A sets merge sync-bit on
45+
- Connection B continues to capture local writes
46+
- [ ] Test fails on current Zig implementation and passes after fix.
47+
- [ ] `make -C zig test-parity` (and/or `make -C zig test-unit`) runs this test.
48+
49+
## Progress Log
50+
### 2025-12-18
51+
- Task created during "update tasks" to invalidate "zig is done".
52+
53+
## Completion Notes
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# TASK-073: Compare Rust integration suite vs Zig harness; create missing-test tasks
2+
3+
## Status
4+
- [ ] Planned
5+
- [ ] Assigned
6+
- [ ] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [ ] Complete
9+
10+
## Priority
11+
high
12+
13+
## Assigned To
14+
(unassigned)
15+
16+
## Parent Docs / Cross-links
17+
- Rust integration suite entrypoint: `core/rs/integration_check/src/lib.rs`
18+
- Rust integration suites:
19+
- `core/rs/integration_check/src/t/automigrate.rs`
20+
- `core/rs/integration_check/src/t/backfill.rs`
21+
- `core/rs/integration_check/src/t/pack_columns.rs`
22+
- `core/rs/integration_check/src/t/pk_only_tables.rs`
23+
- `core/rs/integration_check/src/t/pk_update.rs`
24+
- `core/rs/integration_check/src/t/test_db_version.rs`
25+
- `core/rs/integration_check/src/t/test_cl_set_vtab.rs`
26+
- `core/rs/integration_check/src/t/tableinfo.rs`
27+
- `core/rs/integration_check/src/t/teardown.rs`
28+
- `core/rs/integration_check/src/t/fract.rs`
29+
- Zig harness: `zig/harness/`
30+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
31+
32+
## Description
33+
The repo contains *multiple* test surfaces:
34+
- C test suites (`core/src/*.test.c`)
35+
- Rust integration suite (`core/rs/integration_check/src/t/*.rs`)
36+
- Zig parity/unit/realistic harness (`zig/harness/*`, `zig/test/*.zig`)
37+
38+
To invalidate the hypothesis that the Zig implementation is done, we need a *coverage map* that answers:
39+
- Which Rust/C behaviors are not exercised by Zig tests?
40+
- Which Zig behaviors aren’t cross-checked against Rust/C? (risk of Zig-specific blindspots)
41+
42+
This task builds that map and then produces follow-up task cards for each gap.
43+
44+
## Files to Modify
45+
- `.tasks/backlog/TASK-073-compare-rust-zig-tests.md`
46+
- `research/zig-cr/92-gap-backlog.md`
47+
- `.tasks/backlog/TASK-*.md` (new follow-up tasks created by this task)
48+
49+
## Acceptance Criteria
50+
- [ ] A table exists in this task card mapping:
51+
- Rust integration suite → equivalent Zig test(s) (or "missing")
52+
- C suite → equivalent Zig test(s) (or "missing")
53+
- [ ] For each "missing" row: a new `.tasks/backlog/TASK-*.md` exists, with tight `Files to Modify` and a reproducible command.
54+
- [ ] Gaps are framed from a real-system POV (migrations, multi-conn, on-disk DBs, crash/rollback).
55+
56+
## Progress Log
57+
### 2025-12-18
58+
- Task created during "update tasks" to invalidate "zig is done".
59+
60+
## Completion Notes
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# TASK-074: Cross-implementation wire compatibility — Expand beyond happy path
2+
3+
## Status
4+
- [ ] Planned
5+
- [ ] Assigned
6+
- [ ] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [ ] Complete
9+
10+
## Priority
11+
high
12+
13+
## Assigned To
14+
(unassigned)
15+
16+
## Parent Docs / Cross-links
17+
- Existing script: `zig/harness/test-cross-platform-compat.sh`
18+
- C sync helper reference: `core/src/crsqlite.test.c` (syncLeftToRight)
19+
- Feature matrix: `research/zig-cr/90-feature-matrix.md`
20+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
21+
22+
## Description
23+
A real system will often have heterogeneous peers (mobile, server, browser) and long-lived on-disk databases.
24+
25+
We already have a Zig↔Rust/C compatibility script, but it’s easy for it to be effectively "green" because:
26+
- it can SKIP if the Rust/C extension isn’t built
27+
- it may not cover important edge cases (deletes, PK updates, schema evolution, numeric/text encoding edge cases)
28+
29+
This task strengthens the compatibility proof by expanding the scenario set and making sure CI/local runs cannot silently skip the Rust/C side.
30+
31+
## Files to Modify
32+
- `zig/harness/test-cross-platform-compat.sh`
33+
- `core/Makefile` (only if needed to provide a reproducible build target for the Rust/C loadable extension)
34+
- `.github/workflows/zig-tests.yaml` (optional: ensure Rust/C artifact exists for compat test)
35+
- `research/zig-cr/92-gap-backlog.md`
36+
37+
## Acceptance Criteria
38+
- [ ] Script reliably finds/builds the Rust/C extension (no silent SKIP in CI).
39+
- [ ] New compatibility assertions added for at least:
40+
- deletes + resurrection behavior
41+
- primary key updates
42+
- compound primary keys
43+
- float edge cases (sci notation), blobs, NULLs
44+
- schema evolution (add/remove columns with `crsql_commit_alter`/equivalent)
45+
- [ ] Both directions tested: Zig→Rust/C and Rust/C→Zig.
46+
47+
## Progress Log
48+
### 2025-12-18
49+
- Task created during "update tasks" to invalidate "zig is done".
50+
51+
## Completion Notes

0 commit comments

Comments
 (0)