Skip to content

Commit f62e174

Browse files
delegate round 39: browser polish F15 + WASM baked-in extensions (sqlite-vec/FTS5/JSONB)
TASK-065: Browser multi-tab integration polish (F15) - Verified already correct: tree-shakeable exports, no node deps, clean API - 81 mesh tests pass TASK-067: WASM baked-in extensions - sqlite-vec v0.1.6 statically linked - FTS5 enabled (compile-time) - JSONB enabled (compile-time) - 12 new browser tests (30 total pass) - WASM size: 1.44MB (+100KB for features)
1 parent 123edd0 commit f62e174

14 files changed

+688
-115
lines changed

.tasks/DELEGATE_WORK_HANDOFF.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,129 @@ Size Comparison:
697697
- Browser integration polish F15 remains (packaging/treeshake verification)
698698

699699
---
700+
701+
## Round 2025-12-16 (39) — Browser polish F15 + WASM baked-in extensions
702+
703+
**Tasks executed**
704+
- `.tasks/done/TASK-065-browser-multitab-integration-polish.md`
705+
- `.tasks/done/TASK-067-zig-wasm-baked-in-extensions.md`
706+
707+
**Commits**
708+
- `5dc8b4ce` — delegate round 39: browser polish F15 + WASM baked-in extensions (sqlite-vec/FTS5/JSONB)
709+
710+
**Modified files (root repo)**
711+
- `zig/wasm-build/build-sqlite-wasm.sh` — Added sqlite-vec v0.1.6 download and linking
712+
- `zig/browser-test/tests/crsql-wasm.spec.ts` — Added 12 new extension tests
713+
- `zig/browser-test/fixtures/sql-wasm.js` — Rebuilt WASM bundle
714+
- `zig/browser-test/fixtures/sql-wasm.wasm` — Rebuilt WASM bundle
715+
- `zig/browser-dist/sql-wasm.js` — Rebuilt WASM bundle
716+
- `zig/browser-dist/sql-wasm.wasm` — Rebuilt WASM bundle
717+
- `.tasks/done/TASK-065-browser-multitab-integration-polish.md` — Completed (moved from backlog)
718+
- `.tasks/done/TASK-067-zig-wasm-baked-in-extensions.md` — Completed (moved from backlog)
719+
- `research/zig-cr/92-gap-backlog.md` — Updated status
720+
721+
**Environment**
722+
- OS: darwin (macOS ARM64)
723+
- Tooling: pnpm, vitest 3.2.4, nix, zig (via nix), playwright
724+
725+
**Commands run (exact)**
726+
```bash
727+
# TASK-065 verification
728+
pnpm -F @effect-native/crsql-mesh check
729+
pnpm -F @effect-native/crsql-mesh test --run
730+
pnpm --filter "@effect-native/crsql-mesh" build
731+
732+
# TASK-067 verification
733+
make -C zig test-browser
734+
```
735+
736+
**Outputs (paste)**
737+
738+
<details>
739+
<summary>TASK-065: crsql-mesh tests (81 pass) + TypeScript check + build</summary>
740+
741+
```text
742+
$ pnpm -F @effect-native/crsql-mesh check
743+
> tsc -b tsconfig.json
744+
(no errors)
745+
746+
$ pnpm -F @effect-native/crsql-mesh test --run
747+
✓ test/browser/coordinator-sw.test.ts (12 tests) 5ms
748+
✓ test/browser/coordinator.test.ts (18 tests) 13ms
749+
✓ test/browser/provider.test.ts (25 tests) 43ms
750+
✓ test/IntegrationSqlite.test.ts (3 tests) 31ms
751+
✓ test/Receive.test.ts (4 tests) 43ms
752+
✓ test/Mesh.test.ts (7 tests) 110ms
753+
✓ test/VersionVector.test.ts (3 tests) 44ms
754+
✓ test/Integration.test.ts (4 tests) 54ms
755+
✓ test/Apply.test.ts (5 tests) 60ms
756+
757+
Test Files 9 passed (9)
758+
Tests 81 passed (81)
759+
760+
$ pnpm --filter "@effect-native/crsql-mesh" build
761+
Successfully compiled 11 files with Babel
762+
```
763+
764+
**Result:** No code changes needed — exports already tree-shakeable, no node-only dependencies, clean public surface.
765+
</details>
766+
767+
<details>
768+
<summary>TASK-067: browser tests (30 pass)</summary>
769+
770+
```text
771+
$ make -C zig test-browser
772+
Running 30 tests using 2 workers
773+
774+
✓ 1 tests/multitab-basic.spec.ts › Multi-tab Database Coordination › two tabs can connect to SharedWorker
775+
✓ 2 tests/crsql-wasm.spec.ts › SQLite WASM in Browser › sql.js loads and initializes successfully
776+
... (18 existing tests)
777+
✓ 19 tests/crsql-wasm.spec.ts › Baked-in Extensions › FTS5 › FTS5 virtual table can be created
778+
✓ 20 tests/crsql-wasm.spec.ts › Baked-in Extensions › FTS5 › FTS5 full-text search works
779+
✓ 21 tests/crsql-wasm.spec.ts › Baked-in Extensions › JSON/JSONB Functions › json() function works
780+
✓ 22 tests/crsql-wasm.spec.ts › Baked-in Extensions › JSON/JSONB Functions › json_extract() function works
781+
✓ 23 tests/crsql-wasm.spec.ts › Baked-in Extensions › JSON/JSONB Functions › jsonb() function works (SQLite 3.45+)
782+
✓ 24 tests/crsql-wasm.spec.ts › Baked-in Extensions › JSON/JSONB Functions › json_array() and json_object() work
783+
✓ 25 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec_version() returns a version string
784+
✓ 26 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec_f32() creates a float32 vector
785+
✓ 27 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec_distance_l2() calculates L2 distance
786+
✓ 28 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec_distance_cosine() calculates cosine distance
787+
✓ 29 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec0 virtual table can be created
788+
✓ 30 tests/crsql-wasm.spec.ts › Baked-in Extensions › sqlite-vec Extension › vec0 supports vector insert and KNN query
789+
790+
30 passed (18.0s)
791+
```
792+
793+
**Extensions baked in:**
794+
- **FTS5**: Full-text search (compile-time flag)
795+
- **JSON/JSONB**: JSON1 + JSONB (compile-time flags, JSONB in SQLite 3.45+)
796+
- **sqlite-vec v0.1.6**: Vector similarity search (statically linked)
797+
798+
**WASM size:** 1,440,717 bytes (increased ~100KB due to sqlite-vec)
799+
</details>
800+
801+
**Reproduction steps (clean checkout)**
802+
1. `git clone <repo> && cd cr-sqlite`
803+
2. `cd effect-native && pnpm install`
804+
3. `pnpm -F @effect-native/crsql-mesh check`
805+
4. `pnpm -F @effect-native/crsql-mesh test --run`
806+
5. `pnpm --filter "@effect-native/crsql-mesh" build`
807+
6. `make -C zig test-browser`
808+
809+
**Work summary**
810+
1. **TASK-065 (F15)**: Browser multi-tab integration polish — verified already correct, no changes needed
811+
- Tree-shakeability: explicit named exports, no barrel files
812+
- No node-only dependencies: zero external imports in browser modules
813+
- Clean public surface: Browser namespace export + direct imports supported
814+
815+
2. **TASK-067**: WASM baked-in extensions
816+
- Added sqlite-vec v0.1.6 download and static linking
817+
- FTS5 and JSONB already enabled via compile flags
818+
- 12 new tests proving each extension works
819+
- WASM size increased by ~100KB (acceptable tradeoff for features)
820+
821+
**Known gaps / unverified claims**
822+
- No coverage captured
823+
- `.wishes/wasm-extras.md` satisfied — could move to `.wishes/done/`
824+
825+
---

.tasks/backlog/TASK-065-browser-multitab-integration-polish.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

.tasks/backlog/TASK-067-zig-wasm-baked-in-extensions.md

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# TASK-065: Browser multi-tab integration polish (F15)
2+
3+
## Status
4+
- [x] Planned
5+
- [x] Assigned
6+
- [x] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [x] Complete
9+
10+
## Priority
11+
medium
12+
13+
## Assigned To
14+
subagent (general)
15+
16+
## Parent Docs / Cross-links
17+
- Unified plan (source of truth): `effect-native/.specs/crsql-mesh/plan.md` Section F (F15)
18+
- Gap backlog: `research/zig-cr/92-gap-backlog.md`
19+
20+
## Description
21+
Complete the browser multi-tab integration polish slice from the RGRTDD plan (F15):
22+
23+
- Ensure browser worker modules are tree-shakeable.
24+
- Ensure the `@effect-native/crsql-mesh` public surface for browser multi-tab is clean and minimal.
25+
- Verify build output does not accidentally pull in node-only dependencies.
26+
27+
This task is intended as a packaging/build correctness pass, not feature work.
28+
29+
## Files to Modify
30+
- `effect-native/packages-native/crsql-mesh/src/index.ts`
31+
- `effect-native/packages-native/crsql-mesh/src/browser/index.ts`
32+
- `effect-native/packages-native/crsql-mesh/package.json` (if needed)
33+
- `research/zig-cr/92-gap-backlog.md`
34+
35+
## Acceptance Criteria
36+
- [x] Browser multi-tab exports are available from `@effect-native/crsql-mesh` without importing node-only code paths.
37+
- [x] Verification:
38+
- `pnpm -F @effect-native/crsql-mesh check`
39+
- `pnpm -F @effect-native/crsql-mesh test --run` ✓ (81 tests passed)
40+
- `pnpm --filter "@effect-native/crsql-mesh" build`
41+
42+
## Progress Log
43+
### 2025-12-17
44+
- Task created during "update tasks" reconciliation from `research/zig-cr/92-gap-backlog.md` remaining F15 work.
45+
46+
## Completion Notes
47+
48+
### 2025-12-16 - Completed (no changes needed)
49+
50+
**Analysis Results:**
51+
52+
The browser multi-tab integration is already correctly structured:
53+
54+
1. **Tree-shakeability verified:**
55+
- `src/browser/index.ts` uses explicit named exports (not barrel `export *`)
56+
- Each browser module (`coordinator.ts`, `provider.ts`, `coordinator-sw.ts`) is standalone
57+
- `coordinator-sw.ts` only uses `import type` from `coordinator.ts` (no runtime dependency)
58+
59+
2. **No node-only dependencies:**
60+
- Browser modules have zero external imports - pure TypeScript/browser APIs only
61+
- Verified via ripgrep: no imports from `fs`, `path`, `crypto`, `node:`, `child_process`, `os`
62+
63+
3. **Clean public surface:**
64+
- Main index: `export * as Browser from "./browser/index.js"` (namespace export)
65+
- Direct imports also available: `@effect-native/crsql-mesh/browser/*`
66+
67+
**Verification Commands:**
68+
69+
```
70+
$ pnpm -F @effect-native/crsql-mesh check
71+
> tsc -b tsconfig.json
72+
(no errors)
73+
74+
$ pnpm -F @effect-native/crsql-mesh test --run
75+
✓ test/browser/coordinator-sw.test.ts (12 tests)
76+
✓ test/browser/coordinator.test.ts (18 tests)
77+
✓ test/browser/provider.test.ts (25 tests)
78+
✓ test/IntegrationSqlite.test.ts (3 tests)
79+
✓ test/Receive.test.ts (4 tests)
80+
✓ test/Mesh.test.ts (7 tests)
81+
✓ test/VersionVector.test.ts (3 tests)
82+
✓ test/Integration.test.ts (4 tests)
83+
✓ test/Apply.test.ts (5 tests)
84+
Test Files 9 passed (9)
85+
Tests 81 passed (81)
86+
87+
$ pnpm --filter "@effect-native/crsql-mesh" build
88+
Successfully compiled 11 files with Babel
89+
```
90+
91+
**Files Modified:** None - code already meets all acceptance criteria
92+
93+
**Commit:** N/A (no changes)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# TASK-067: Zig WASM baked-in extensions (sqlite-vec / FTS / BJSON)
2+
3+
## Status
4+
- [x] Planned
5+
- [x] Assigned
6+
- [x] In Progress
7+
- [ ] Blocked (reason: ...)
8+
- [x] Complete
9+
10+
## Priority
11+
medium
12+
13+
## Assigned To
14+
subagent (general)
15+
16+
## Parent Docs / Cross-links
17+
- Wish: `.wishes/wasm-extras.md`
18+
- Zig wasm build scripts: `zig/wasm-build/`
19+
- Gap backlog: `research/zig-cr/92-gap-backlog.md` (add a new section under Gaps)
20+
21+
## Description
22+
Our wasm build does not support loadable extensions. This task bakes a small set of useful extensions into the wasm artifact:
23+
24+
- `sqlite-vec`
25+
- Full text search (FTS)
26+
- BJSON
27+
28+
This is strictly about build composition and test evidence; not about exposing a large JS API surface.
29+
30+
## Files to Modify
31+
- `zig/wasm-build/build-sqlite-wasm.sh`
32+
- `zig/browser-test/tests/crsql-wasm.spec.ts` (add assertions proving extensions present)
33+
- `research/zig-cr/92-gap-backlog.md`
34+
35+
## Acceptance Criteria
36+
- [x] `zig/browser-test/tests/crsql-wasm.spec.ts` contains deterministic evidence that each extension is available.
37+
- [x] The wasm build includes the extensions without requiring dynamic loading.
38+
- [x] Verification:
39+
- `make -C zig test-browser` (or the repo's existing browser test command)
40+
41+
## Progress Log
42+
### 2025-12-17
43+
- Task created from `.wishes/wasm-extras.md` during "update tasks".
44+
45+
### 2025-12-16
46+
- Modified `zig/wasm-build/build-sqlite-wasm.sh`:
47+
- Added Step 2 to download sqlite-vec v0.1.6 amalgamation from GitHub releases
48+
- Updated glue code (Step 3) to register sqlite-vec as an auto-extension alongside CR-SQLite
49+
- Added compilation of `sqlite-vec.o` with `-DSQLITE_CORE -DSQLITE_VEC_OMIT_FS -DNDEBUG` flags
50+
- Added `sqlite-vec.o` to the final linking step
51+
- Added "Baked-in Extensions" test suite to `zig/browser-test/tests/crsql-wasm.spec.ts`:
52+
- FTS5 tests: virtual table creation, full-text search via COUNT(*)
53+
- JSON/JSONB tests: `json()`, `json_extract()`, `jsonb()`, `json_array()`, `json_object()`
54+
- sqlite-vec tests: `vec_version()`, `vec_f32()`, `vec_distance_l2()`, `vec_distance_cosine()`, `vec0` virtual table, KNN queries
55+
- Copied updated WASM files to `zig/browser-test/fixtures/` and `zig/browser-dist/`
56+
- All 30 browser tests pass
57+
58+
## Completion Notes
59+
### 2025-12-16
60+
- **Extensions successfully baked into WASM build:**
61+
- **FTS5**: Full-text search enabled via `-DSQLITE_ENABLE_FTS5` flag (already in SQLite)
62+
- **JSON/JSONB**: JSON1 enabled via `-DSQLITE_ENABLE_JSON1` flag; JSONB built into SQLite 3.45+
63+
- **sqlite-vec v0.1.6**: Statically linked, auto-initialized via `sqlite3_auto_extension()`
64+
- **WASM size**: 1,440,717 bytes (increased from 1,340,272 due to sqlite-vec)
65+
- **Test verification command**: `make -C zig test-browser` - 30/30 tests pass
66+
- **Commit**: (pending)

0 commit comments

Comments
 (0)