Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
fc99998
Add evoluError tab channel and error handling
steida Feb 13, 2026
f16f563
Only transpile workspace packages in dev
steida Feb 14, 2026
c3e32b0
Update pnpm-lock.yaml
steida Feb 14, 2026
e62d12a
Add microtask batch utility
steida Feb 14, 2026
5d7cf73
Add ref count utility
steida Feb 14, 2026
31e07eb
Implement mutation methods
steida Feb 14, 2026
9d3a49e
Add commit batches prompt
steida Feb 14, 2026
da75834
Renamed local-first worker module to Shared and aligned shared worker…
steida Feb 14, 2026
019ad76
Add testCreateWorker and worker tests
steida Feb 14, 2026
b90fae5
Wire createEvolu to DB worker init
steida Feb 14, 2026
d4fb5ba
Wire platform DB workers and worker rename
steida Feb 14, 2026
a986d23
Add leader lock and worker init wiring
steida Feb 14, 2026
cc87fde
Add canonical test name constants
steida Feb 14, 2026
857608f
Rename common test deps module
steida Feb 14, 2026
d5e7e3c
Add React Native leader lock tests
steida Feb 14, 2026
27a34ec
Add web leader lock browser tests
steida Feb 14, 2026
cb1e7e0
Use store-only worker console output
steida Feb 14, 2026
f05ec75
Use Run<D> type for run.daemon
steida Feb 14, 2026
af7aca4
Update TreeShaking.test.ts
steida Feb 14, 2026
2cc6272
Sort imports
steida Feb 14, 2026
2a585dc
Centralize deterministic test values
steida Feb 14, 2026
fb46547
Use deterministic AppOwner in playground
steida Feb 14, 2026
fefc8e3
Refactor db worker init flow
steida Feb 14, 2026
db759d4
Added broker channel wiring and leader acquired output handling
steida Feb 15, 2026
a2a448d
Added typed NativeMessagePort generics
steida Feb 15, 2026
746ea84
Refactored local-first worker channel wiring
steida Feb 15, 2026
0b390f6
Clarified SharedWorker communication comment
steida Feb 15, 2026
0bbef0a
Simplified worker deps and forwarded DbWorker console entries
steida Feb 15, 2026
57d2390
Wired DbWorker init payload and worker output flow
steida Feb 15, 2026
d4f0e5f
Wired sqlite driver into React Native deps
steida Feb 15, 2026
096326e
Documented type aliases for composed deps
steida Feb 15, 2026
7f12041
Refactored DB worker startup to initialize schema and bootstrap clock…
steida Feb 15, 2026
f94006d
Refactored SQLite APIs to throw-first semantics and aligned protocol/…
steida Feb 15, 2026
1f7be0d
Update pnpm-lock.yaml
steida Feb 15, 2026
b9fcb47
Add getOk for never-error Results
steida Feb 15, 2026
af2e3f6
Use getOk in SQLite setup paths
steida Feb 15, 2026
717abb4
Upgrade Biome to v2.4.0 and update config
steida Feb 15, 2026
c089ae9
Queue mutations, add quarantine, rename messages
steida Feb 16, 2026
b9bfdba
Added typed NativeMessagePort generics
steida Feb 15, 2026
73fd300
Refactored local-first worker channel wiring
steida Feb 15, 2026
63c3ada
Clarified SharedWorker communication comment
steida Feb 15, 2026
e2a02ff
Simplified worker deps and forwarded DbWorker console entries
steida Feb 15, 2026
57d7a98
Wired DbWorker init payload and worker output flow
steida Feb 15, 2026
1eca3d9
Wired sqlite driver into React Native deps
steida Feb 15, 2026
4daa253
Refactored SQLite APIs to throw-first semantics and aligned protocol/…
steida Feb 15, 2026
5c6e4c0
Add getOk for never-error Results
steida Feb 15, 2026
c89f42c
Use getOk in SQLite setup paths
steida Feb 15, 2026
def6291
chore(sync): resolve common-v8 merge conflicts and verify fixes
miccy Feb 16, 2026
f79c094
feat: Introduce console dependency and logging level control for work…
miccy Feb 16, 2026
26ef922
docs: add common-v8 parity plan outlining compatibility goals and exe…
miccy Feb 16, 2026
4c5ec88
Added broker channel wiring and leader acquired output handling
steida Feb 15, 2026
6e14edf
chore(sync): backport shared worker wiring and stabilize mutation queue
miccy Feb 16, 2026
e07ee5e
Simplified worker deps and forwarded DbWorker console entries
steida Feb 15, 2026
0c29b0b
Wired DbWorker init payload and worker output flow
steida Feb 15, 2026
8b424a8
chore(sync): apply biome fixes after shared worker backport
miccy Feb 16, 2026
dc4c658
chore(sync): align common Db/Shared contract with common-v8
miccy Feb 16, 2026
4f17691
chore(sync): keep Bun/Web workers on experimental Db protocol aliases
miccy Feb 16, 2026
a725c36
docs(sync): update common-v8 parity matrix and remaining divergence
miccy Feb 16, 2026
c0469d2
chore(sync): mark upstream/common-v8 ancestry merged
miccy Feb 16, 2026
b3db45a
Initial plan
Copilot Feb 16, 2026
bae926a
Merge pull request #40 from SQLoot/copilot/sub-pr-39
miccy Feb 16, 2026
cad3fbd
feat: remove dotenv@16.6.1 from bun.lock
miccy Feb 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .ai/knowledge/common-v8-parity-plan-2026-02-16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Common-v8 Parity Plan (Bun-first)

## Goal

Reach practical `upstream/common-v8` compatibility for architecture/API/behavior while keeping:

- `bun` runtime and package manager
- `biome` instead of eslint/prettier
- reduced dependencies and Bun-native replacements where beneficial

## Hard Rules

- No wholesale merge of upstream branch.
- No return of removed tooling (`pnpm`, `pnpx`, `eslint`, `prettier`).
- Every upstream commit must be classified:
- `verified-equivalent`
- `pending-adopt`
- `intentional-divergence`
- Any divergence must include reason + impact.

## Verification Gates

- `bunx tsc --build packages/common packages/web packages/react-native packages/nodejs`
- `bunx vitest run` for targeted suites around touched areas
- `bun run verify:fast`
- `SYNC_GUARD_MAIN_REF=miccy-dev bun run sync:guard:common-v8:strict`

## Upstream Commit Matrix (Current Snapshot)

Source: `git cherry -v miccy-dev upstream/common-v8`

| Upstream | Subject | Status | Local Note |
|---|---|---|---|
| `fc99998` | Add evoluError tab channel and error handling | `verified-equivalent` | Implemented via local worker/tab error flow (`EvoluTabOutput`, `InitTab`, shared `evoluError` store). |
| `c3e32b0` | Update pnpm-lock.yaml | `intentional-divergence` | Bun lockfile is authoritative. |
| `e62d12a` | Add microtask batch utility | `verified-equivalent` | Present in local fork (`microtask batch` utility + export). |
| `31e07eb` | Implement mutation methods | `verified-equivalent` | `createEvolu` mutation dispatch/coalescing is implemented and covered; queue processing is serialized across microtasks. |
| `da75834` | Rename worker module to Shared | `verified-equivalent` | `Shared.ts` is now present and exported; legacy `Worker.ts` stays as compatibility layer. |
| `019ad76` | Add testCreateWorker and worker tests | `verified-equivalent` | Backported: `testCreateWorker`, `testCreateMessageChannel`, `testCreateMessagePort`, `testCreateSharedWorker` + `packages/common/test/Worker.test.ts`. |
| `b90fae5` | Wire createEvolu to DB worker init | `verified-equivalent` | Local runtime already wires InitEvolu + DB worker init flow; covered by local-first Evolu tests. |
| `d4fb5ba` | Wire platform DB workers and worker rename | `intentional-divergence` | Keep Bun-first Worker/DbWorker layout, but `local-first` now exports upstream `Db` contract and moves fork-only protocol under `Experimental*` aliases. |
| `a986d23` | Add leader lock and worker init wiring | `verified-equivalent` | LeaderLock wiring is present across common/web/react-native runtime deps and tests. |
| `cc87fde` | Add canonical test name constants | `verified-equivalent` | `testName`/`testAppName` present locally. |
| `857608f` | Rename common test deps module | `verified-equivalent` | Test helper imports now converge on `_deps.ts`; `_deps.nodejs.ts` left as compatibility re-export shim. |
| `d5e7e3c` | Add React Native leader lock tests | `verified-equivalent` | RN leader lock tests are present and green. |
| `27a34ec` | Add web leader lock browser tests | `verified-equivalent` | Web leader lock browser tests are present and green. |
| `cb1e7e0` | Use store-only worker console output | `verified-equivalent` | Worker bootstrap now uses `createWorkerRun` + store output forwarding path. |
| `f05ec75` | Use Run<D> type for run.daemon | `verified-equivalent` | Already ported in local fork. |
| `af7aca4` | Update TreeShaking.test.ts | `intentional-divergence` | Bun-first keeps normalized tree-shaking snapshot to stabilize cross-runtime size variance. |
| `2cc6272` | Sort imports | `intentional-divergence` | Non-functional; handled by Biome formatting policy. |
| `2a585dc` | Centralize deterministic test values | `verified-equivalent` | Already ported. |
| `fb46547` | Use deterministic AppOwner in playground | `verified-equivalent` | Already ported. |
| `fefc8e3` | Refactor db worker init flow | `verified-equivalent` | Stack ownership + daemon init flow is already present in local worker startup path. |
| `db759d4` | Broker channel wiring + leader acquired output | `verified-equivalent` | Leader channel wiring and `LeaderAcquired` handling are implemented and regression-tested. |
| `a2a448d` | Typed NativeMessagePort generics | `verified-equivalent` | Already ported. |
| `746ea84` | Refactored local-first worker channel wiring | `verified-equivalent` | Already ported with Bun-first file layout. |
| `0b390f6` | Clarified SharedWorker communication comment | `verified-equivalent` | Doc-level parity covered in local comments/docs. |
| `0bbef0a` | Simplified worker deps + forwarded DbWorker console entries | `verified-equivalent` | Ported behavior; continue regression checks. |
| `57d2390` | Wired DbWorker init payload and worker output flow | `verified-equivalent` | Ported with local worker protocol/wiring. |
| `d4f0e5f` | Wired sqlite driver into React Native deps | `verified-equivalent` | Ported. |
| `096326e` | Documented type aliases for composed deps | `intentional-divergence` | Upstream `apps/web` docs were removed from this fork; docs parity is tracked in `website/apps/docs`. |
| `7f12041` | Refactored DB worker startup to initialize schema/bootstrap clock | `verified-equivalent` | `Db.ts` is now aligned with upstream startup/bootstrap flow (clock + schema init + quarantine reapply) with Bun-first cleanup only. |
| `f94006d` | SQLite throw-first semantics + protocol/storage alignment | `verified-equivalent` | Ported in local fork (conflict-resolved variant). |
| `1f7be0d` | Update pnpm-lock.yaml | `intentional-divergence` | Bun lockfile only. |
| `af2e3f6` | Use getOk in SQLite setup paths | `verified-equivalent` | Ported. |
| `717abb4` | Upgrade Biome to v2.4.0 and update config | `verified-equivalent` | Ported via local dependency/config update. |
| `c089ae9` | Queue mutations, add quarantine, rename messages | `intentional-divergence` | Upstream `Db.ts`/`Shared.ts` queue+ack path is now aligned; local `Evolu.ts` keeps Bun-first direct `DbWorkerClient` queue path as internal runtime divergence. Public API remains compatible. |

## Remaining Blocking Gaps

No unresolved blocking gaps in the tracked `common-v8` matrix.

Open divergence to track:

1. `c089ae9` runtime path in `Evolu.ts` remains intentionally Bun-first (direct DbWorker client queue) instead of upstream SharedWorker mutation queue orchestration.

## Execution Order

1. Worker/runtime parity batch:
- `a986d23`, `fefc8e3`, `db759d4`, `b90fae5`, `d4fb5ba`, `857608f`, `d5e7e3c`, `27a34ec`, `cb1e7e0`
2. Mutation queue/protocol batch:
- `31e07eb`, `c089ae9`
3. DB startup/docs batch:
- `7f12041`, `019ad76`, `af7aca4`, `096326e`

## Bun-native Replacement Opportunities (After Parity)

- Keep `webpack` only where explicitly needed for compatibility snapshots (tree-shaking baseline).
- Add optional Bun-native comparison path (`bun build --minify`) for internal perf tracking, not as baseline replacement.
- Review and remove redundant Node-era tooling wrappers where Bun provides equivalent runtime/build/test behavior.
12 changes: 12 additions & 0 deletions .ai/memory/user-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@
## Specifika Projektu
- **Aktuální stav**:
- **Kritické Todo**:

## Sync Pravidla (`upstream/common-v8` -> `evolu-plan-b`)
- **Baseline**: `common-v8` je výchozí architektura/UX/API kompatibilita.
- **Bez wholesale merge**: nikdy neprovádět slepé 1:1 mergnutí celé větve, které vrací odstraněné dependency/tooling.
- **Bun-first/Biome-first**: zachovat `bun` + `biome`, nevracet `pnpm`, `pnpx`, `eslint`, `prettier` ani jejich workflow.
- **Commit-parity workflow**: každou upstream změnu mapovat jako `adopt exact` / `equivalent` / `intentional divergence`.
- **Povinný reporting odchylek předem**: pokud nebude něco implementováno nebo bude řešeno jinak, vždy předem uvést důvod, dopad a návrh.
- **Performance & deps policy**: aktivně hledat náhrady 3rd-party knihoven nativními Bun funkcemi a hlásit je; preferovat méně závislostí a vyšší výkon.
- **No chaos refactors**: nepřesouvat naming/soubory bez jasného přínosu (výkon, stabilita, kompatibilita).
- **Keep local supersets**: pokud máme navíc oproti upstreamu (vyřešený issue, lepší implementace, funkce navíc), nikdy to nerevertovat, pokud je zachovaná upstream kompatibilita.
- **Testy můžou být napřed**: aktivně přidávat/rozšiřovat test coverage i nad rámec upstreamu, pokud to zvyšuje jistotu kompatibility a stability.
- **Escalation style**: při nalezení upstream chyby nebo lepší Bun varianty nejdřív zastavit a dodat stručný report: problém -> dopad -> návrh -> riziko.
28 changes: 24 additions & 4 deletions .changeset/sqlite-refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@
"@evolu/react-native": major
---

Refactored createSqlite and CreateSqliteDriver to use Task
Refactored SQLite integration to use Task and throw-first semantics

- Changed `createSqlite` to `Task<Sqlite, SqliteError, CreateSqliteDriverDep>`
- Changed `CreateSqliteDriver` to `Task<SqliteDriver, SqliteError>`
- Changed `createSqlite` to `Task<Sqlite, never, CreateSqliteDriverDep>`
- Changed `CreateSqliteDriver` to `Task<SqliteDriver>`
- Removed `SqliteError` from SQLite driver/task APIs
- Changed `Sqlite.exec` to return `SqliteExecResult` directly (no `Result<..., SqliteError>`)
- Changed `Sqlite.transaction` to support callbacks returning either `Result<T, E>` or `void` (no `SqliteError` in the error channel)
- Changed `Sqlite.export` to return `Uint8Array` directly (no `Result<..., SqliteError>`)
- Simplified `SqliteDriver.exec` by removing the `isMutation` parameter — the driver now determines read vs write internally
- Replaced `options.memory` and `options.encryptionKey` with a discriminated `options.mode` field (`"memory"` | `"encrypted"`)
- Added 100% test coverage for better-sqlite3 and WASM SQLite drivers
- Updated Expo and op-sqlite drivers to match the new API

Why `SqliteError` was removed:

- In Evolu, SQLite runs in-process. Failures are infrastructure-level and unrecoverable at the call site.
- Wrapping these failures as `Result` values did not create meaningful recovery paths; callers still had to fail.
- The correct behavior is to let such failures throw and surface them through platform `createRun` global handlers (web, nodejs, react-native), which report uncaught errors via Evolu `console.error`.
- Evolu also propagates `console.error` entries through its messaging layer into the shared `evoluError` global store, so app-level error subscriptions still receive these failures.

Boundary handling:

- At protocol boundaries (for example Protocol ↔ Storage), error handling remains explicit.
- Since storage implementations may throw, boundary code uses `try/catch`, logs with `console.error(error)`, and returns protocol-level outcomes.
- Protocol handles all thrown errors as boundary concerns, without coupling to SQLite-specific error types.

Developer experience:

- This change reduces boilerplate (`if (!result.ok)` branches and `SqliteError` plumbing), making infrastructure code less verbose and easier to follow.
10 changes: 2 additions & 8 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"noExplicitAny": "off",
"noImplicitAnyLet": "off",
"useIterableCallbackReturn": "off",
"noImportCycles": "error",
"noThenProperty": "off",
"noAssignInExpressions": "off"
},
Expand All @@ -54,14 +55,7 @@
"security": {
"noDangerouslySetInnerHtml": "warn"
},
"nursery": {
"noImportCycles": {
"level": "error",
"options": {
"ignoreTypes": true
}
}
}
"nursery": {}
}
},
"javascript": {
Expand Down
Loading