Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
49da337
feat: Implement owner write key storage and validation, and enhance S…
miccy Feb 27, 2026
05da4d1
test(nodejs,common): expand worker/sqlite branch coverage
miccy Feb 27, 2026
477428f
test(common): extend db internal coverage for eviction and error bran…
miccy Feb 27, 2026
00cbaeb
test(common): push Db worker/init branch coverage over gate
miccy Feb 27, 2026
1ddc253
test(web): add DbWorker re-init and invalid-owner scenarios
miccy Feb 27, 2026
43906e1
test(common): broaden sync lifecycle and storage branch coverage
miccy Feb 27, 2026
63355b2
test(common): harden sync scenarios and raise branch coverage
miccy Feb 27, 2026
d6f818c
test(web): extend dbworker state-machine coverage
miccy Feb 27, 2026
ea088c7
refactor(web): inject dbworker clock and speed watchdog tests
miccy Feb 27, 2026
27f6d8d
test(web): cover evolu adapters and platform reload path
miccy Feb 27, 2026
f283c0c
test(common): add coverage for Kysely JSON helpers
miccy Feb 27, 2026
2736356
test(web): cover worker wrappers and deprecated scopes
miccy Feb 27, 2026
6653d54
test(common): fix Kysely test import ordering for Biome
miccy Feb 27, 2026
c18a477
test(common): expand schema and error branch coverage
miccy Feb 27, 2026
71ce228
fix(common): guarantee string fallback in safelyStringifyUnknownValue
miccy Feb 27, 2026
4ddb510
docs(ai): refresh coverage progress snapshot and quick-win backlog
miccy Feb 27, 2026
69e3811
test(local-auth): expand common and web edge-case coverage
miccy Feb 27, 2026
67f34c7
test(relay): cover zero-byte and mutex-abort write paths
miccy Feb 27, 2026
6a5a6af
docs(ai): refresh local auth and relay coverage status
miccy Feb 27, 2026
f3735c2
refactor(web): inject sqlite-wasm loader seam and cover OPFS init bra…
miccy Feb 27, 2026
8268b9b
test(protocol,bun): cover protocol error branches and bun db worker e…
miccy Feb 27, 2026
0a6a887
docs(readme): add integration matrix and upstream diff overview
miccy Feb 27, 2026
7143de6
docs(readme): add planned integrations roadmap table
miccy Feb 27, 2026
dc27ec8
docs(readme): replace low-fit integrations with must-have frameworks
miccy Feb 27, 2026
3bd1978
test(web): cover shared worker bootstrap module
miccy Feb 27, 2026
7ed25e7
test(nodejs): add relay adapter integration coverage
miccy Feb 27, 2026
0be7caa
build(coverage): merge bun lcov into summary report
miccy Feb 27, 2026
298cea6
test(coverage): add quick-win edge case coverage
miccy Feb 27, 2026
5e8ac52
test(nodejs): cover relay subscribe and restart paths
miccy Feb 27, 2026
e61403e
test(web): cover shared initPromise failure cleanup
miccy Feb 27, 2026
308958f
fix(nodejs): use daemon runner for relay ws message handling
miccy Feb 27, 2026
211de29
docs(coverage): refresh adapter hardening snapshot
miccy Feb 27, 2026
bc0d109
Update `bplist-parser` to `0.3.2` and remove the `jest-haste-map/fsev…
miccy Feb 27, 2026
6456312
test(web): stabilize DbWorker timing-sensitive CI scenarios
miccy Feb 27, 2026
fff16c9
test(web): fix dbworker race handling without timeout masking
miccy Feb 27, 2026
6d9692f
fix(cr): address copilot review findings on pr-53
miccy Feb 27, 2026
7a48a5b
fix(cr): apply relevant coderabbit findings for pr-53
miccy Feb 27, 2026
53f9e29
fix(cr): apply remaining review findings and stabilize coverage gate
miccy Feb 27, 2026
b43aff5
chore: Update various dependencies and add new ones in bun.lock.
miccy Feb 27, 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
94 changes: 94 additions & 0 deletions .ai/knowledge/07-coverage-progress-2026-02-27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Coverage Progress (2026-02-27)

## Context

This note tracks the `P0+P1` coverage hardening wave on top of `origin/main`.
The new file-level gates are implemented by `scripts/coverage-file-gate.mts` and root scripts:

- `bun run coverage:gate:p0`
- `bun run coverage:gate:p1`

## Current Snapshot (from `bun run test:coverage` on branch `test-coverage`)

### P0 target files (target: `>=90% statements` and `>=90% branches`)

| File | Statements | Branches | Status |
|---|---:|---:|---|
| `packages/common/src/local-first/Sync.ts` | 96.83% | 90.83% | ✅ |
| `packages/common/src/local-first/Db.ts` | 99.47% | 91.66% | ✅ |
| `packages/common/src/local-first/Worker.ts` | 95.23% | 100.00% | ✅ |
| `packages/web/src/local-first/DbWorker.ts` | 98.91% | 93.47% | ✅ |

### P1 target files

| File | Target | Current | Status |
|---|---|---|---|
| `packages/common/src/local-first/LocalAuth.ts` | `>=75 / >=60` | `100.00 / 94.11` | ✅ |
| `packages/web/src/local-first/LocalAuth.ts` | `>=75 / >=60` | `100.00 / 92.30` | ✅ |
| `packages/nodejs/src/Worker.ts` | `>=90 / >=85` | `100.00 / 100.00` | ✅ |
| `packages/nodejs/src/Sqlite.ts` | `>=90 / >=85` | `100.00 / 93.75` | ✅ |

Coverage gate status:

- `bun run coverage:gate:p0` ✅
- `bun run coverage:gate:p1` ✅

## Recent Additions (latest wave)

- Adapter/wrapper coverage:
- `packages/web/test/Evolu.test.ts`
- `packages/web/test/Worker.test.ts`
- `packages/react-web/test/local-first/Evolu.test.ts`
- `packages/nodejs/test/WebPlatform.test.ts`
- Common helper/runtime branch coverage:
- `packages/common/test/local-first/Kysely.test.ts`
- `packages/common/test/local-first/Schema.test.ts` (index add/drop, `createQueryBuilder` options, `getEvoluSqliteSchema`)
- `packages/common/test/Error.test.ts` (`handleGlobalError` branches)
- `packages/common/test/String.test.ts` (new file)
- `packages/common/test/local-first/LocalAuth.test.ts` (mnemonic path, missing account, username fallback, unregister without fallback owner)
- `packages/web/test/LocalAuth.test.ts` (credential throw/missing userHandle/legacy metadata/create-null branches)
- `packages/common/test/local-first/Relay.test.ts` (zero-byte write path and mutex-abort propagation)
- Small runtime hardening:
- `packages/common/src/String.ts` now guarantees `string` return even when `JSON.stringify` returns `undefined` (`symbol` case).

## Runtime Adapter Hardening Wave (Relay + DbWorker)

- `packages/nodejs/test/Relay.test.ts`
- Added deterministic websocket scenarios for `subscribe -> broadcast -> unsubscribe`.
- Added restart scenario with existing relay DB file.
- `packages/web/test/DbWorker.test.ts`
- Added failure-race coverage where follower waits on failing shared `initPromise` and later recovery succeeds.
- `packages/web/src/local-first/DbWorker.ts`
- Added optional test hook `createDriver` into `runWebDbWorkerPortWithOptions` for deterministic init-failure injection (runtime default unchanged).
- `packages/nodejs/src/local-first/Relay.ts`
- Fixed WS message handling lifecycle to use daemon runner deps (`_run.daemon.addDeps(...)`) so callbacks are not aborted after `startRelay` returns.
- Kept runtime payload path simple and Bun/Node compatible (`Buffer.from(...)` for outbound binary sends).

## Quick-Win Backlog (post P0/P1)

Prioritized by risk + effort for next PR slices:

1. `packages/web/src/Sqlite.ts` (`82.92% / 76.92%`, missing `3/13` branches)
- Remaining branches are OPFS init paths in main thread (`encrypted/default`) and warning fallback; deterministic coverage likely needs injectable sqlite-wasm facade.
2. `packages/common/src/local-first/Protocol.ts` (`92.93% / 88.83%`, missing `24/215`)
- Slightly below 90 branch; higher complexity than the three items above.
3. `packages/common/src/Console.ts` (`84.21% / 84.00%`, missing `8/50`)
- Moderate complexity; mostly branch-focused unit tests.
4. `packages/common/src/local-first/Relay.ts` (`96.00% / 85.00%`, missing `3/20`)
- Small remaining branch gap after latest write-path additions.
5. `packages/nodejs/src/local-first/Relay.ts` (`97.77% / 81.25%`, missing `3/16`)
- Remaining branch gap is now isolated in guarded branches around owner auth and ws event variants; can be closed with focused adapter tests.
6. `packages/common/src/Type.ts` (`73.50% / 68.32%`, missing `121/382`)
- Big-impact but not a quick win; needs dedicated focused campaign.

## Commit Trace (current head segment)

- `308958f4` `fix(nodejs): use daemon runner for relay ws message handling`
- `e61403e8` `test(web): cover shared initPromise failure cleanup`
- `5e8ac520` `test(nodejs): cover relay subscribe and restart paths`
- `67f34c74` `test(relay): cover zero-byte and mutex-abort write paths`
- `69e3811d` `test(local-auth): expand common and web edge-case coverage`
- `4ddb510c` `docs(ai): refresh coverage progress snapshot and quick-win backlog`
- `71ce2289` `fix(common): guarantee string fallback in safelyStringifyUnknownValue`
- `c18a4777` `test(common): expand schema and error branch coverage`
- `6653d541` `test(common): fix Kysely test import ordering for Biome`
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,73 @@ Primary goals:

Evolu is a TypeScript library and local-first platform.

## Integration Matrix

Coverage snapshot date: `2026-02-27` (from `bun run test:coverage` and `bun run test:coverage:bun`).

| Package | Supported Versions | Implementation Status | Coverage (Statements / Branches) | Notes |
| --- | --- | --- | --- | --- |
| `@evolu/common` | Node `>=24.0.0` | Stable core | `94.47% / 89.57%` | Main engine + local-first protocol/runtime. |
| `@evolu/web` | `@evolu/common ^7.4.1` | Stable | `99.33% / 93.71%` | Browser runtime (Worker/SharedWorker/Web Locks path). |
| `@evolu/nodejs` | Node `>=24.0.0`, `@evolu/common ^7.4.1` | Stable | `95.74% / 87.50%` | Includes relay adapter hardening (WS lifecycle + subscribe/broadcast/unsubscribe + restart coverage). |
| `@evolu/react-web` | React `>=19`, React DOM `>=19`, `@evolu/web ^2.4.0` | Stable thin adapter | `100% / 100%` | Thin web integration wrapper. |
| `@evolu/react-native` | React Native `>=0.81`, Expo `>=54`, `@op-engineering/op-sqlite >=12` | Active hardening | `20.65% / 13.11%` | Core adapters are covered; broader suite is backlog. |
| `@evolu/react` | React `>=19` | Wrapper support | `0% / 0%` | Hook wrappers; coverage expansion planned. |
| `@evolu/vue` | Vue `>=3.5.29` | Wrapper support | `0% / 0%` | Composition API wrappers; coverage expansion planned. |
| `@evolu/svelte` | Svelte `>=5.53.3`, `@evolu/web ^2.4.0` | Wrapper support | `0% / 0%` | Store-based wrappers; coverage expansion planned. |
| `@evolu/bun` (private) | `@evolu/common ^7.4.1`, Bun `1.3.x` | Experimental adapter | `100% / 100%` | Measured via Bun coverage runner on `BunDbWorker.ts`. |

## Planned Integrations (Roadmap View)

| Integration | Fit | Priority | Expected Path | Main Risk / Blocker |
| --- | --- | --- | --- | --- |
| Next.js (App Router) | Very high | P0 | Official `@evolu/react-web` guide + production example for Server/Client boundaries. | SSR/client boundary handling and Worker lifecycle in edge runtimes. |
| TanStack Start | Very high | P0 | Use `@evolu/react` + `@evolu/web`, focus on SSR/client boundary docs and example app. | SSR edge cases (worker lifecycle and hydration boundary). |
| Astro | High | P0 | Client-island integration on top of `@evolu/web`, starter template + docs. | Island hydration timing and worker boot ordering. |
| SvelteKit | High | P1 | `@evolu/svelte` + `@evolu/web` reference app with SSR-aware browser-only init. | Avoiding server-side execution for browser worker primitives. |
| Nuxt 3 | High | P1 | Vue composables + client-only plugin/module (`@evolu/vue` + `@evolu/web`). | Nitro/SSR split and client plugin ordering. |
| Remix / React Router | High | P1 | React adapter with explicit browser init boundaries and route loader guidance. | Loader/action patterns can accidentally cross server/client boundary. |
| Tauri | High | P1 | Web runtime in WebView + optional Rust-side relay bridge for desktop sync scenarios. | Packaging/runtime differences across desktop targets. |
| Electron | High | P1 | Reuse web runtime in renderer + optional Node relay bridge in main process. | Multi-process lifecycle and secure IPC boundaries. |
| Capacitor (Ionic) | Medium | P2 | Reuse web runtime in WebView first, then mobile storage/perf hardening. | Mobile WebView storage consistency and background lifecycle constraints. |
| Flutter | Medium/Low | P2 | Separate adapter/SDK (likely not a thin wrapper) or protocol-level bridge. | Different runtime/language model (Dart), no direct reuse of TS hooks. |

Current recommendation:

- Build first-class examples for `Next.js`, `TanStack Start`, and `Astro`.
- Follow with `SvelteKit`, `Nuxt`, `Remix`, and `Tauri/Electron` runtime guides.
- Treat `Flutter` as a separate SDK/bridge effort, not a quick wrapper.
- Keep protocol/API parity first; add adapters only where lifecycle/storage semantics are clear.

## `@evolu/common` Compatibility and Third-Party Dependencies

- Package version: `7.4.1`
- Runtime baseline: Node `>=24.0.0`
- Monorepo toolchain baseline: Bun `1.3.10`

Third-party runtime dependencies used by `@evolu/common`:

| Dependency | Why It Is Used |
| --- | --- |
| `@noble/ciphers` | Audited cryptographic ciphers for encryption flows. |
| `@noble/hashes` | Audited hash primitives used by protocol/auth internals. |
| `@scure/bip39` | Mnemonic handling for owner/account recovery flows. |
| `disposablestack` | Disposable stack compatibility utility for cleanup semantics. |
| `kysely` | Typed SQL query builder integration. |
| `msgpackr` | Binary message serialization for protocol payloads. |
| `zod` | Runtime schema validation and parsing. |

Dependency policy:

- No dependency downgrades in sync waves.
- Sync waves are periodic coordinated dependency sync batches across packages and CI lanes.
- Prefer native Bun/runtime APIs where practical.
- Keep API/protocol compatibility with upstream.

## Fork Diff vs Upstream

For a concise overview of what this fork changes, why, and what is intentionally extra, see [UPSTREAM_DIFF.md](./UPSTREAM_DIFF.md).

## Documentation

For detailed information and usage examples, please visit [evolu.dev](https://www.evolu.dev).
Expand All @@ -32,7 +99,7 @@ To chat with other community members, you can join the [Evolu Discord](https://d
Evolu monorepo uses [Bun](https://bun.sh).

> [!NOTE]
> The Evolu monorepo is verified to run under **Bun 1.3.9** in combination with **Node.js >=24.0.0**. This compatibility is explicitly tested in CI.
> The Evolu monorepo is verified to run under **Bun 1.3.10** in combination with **Node.js >=24.0.0**. This compatibility is explicitly tested in CI.

Install dependencies:

Expand Down
35 changes: 35 additions & 0 deletions UPSTREAM_DIFF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Evolu Plan B vs Upstream Evolu (High-Level)

This document summarizes the main differences between `SQLoot/evolu-plan-b` and upstream `evoluhq/evolu`.

Scope: high-level product and engineering deltas, not a full commit-by-commit changelog.

## What Is Different

| Area | Plan B Delta | Why |
| --- | --- | --- |
| Tooling baseline | Bun-first monorepo workflows (`bun install`, `bun run ...`) with Turborepo orchestration. | Faster local workflows and a single runtime/tooling story. |
| Formatting and linting | Biome-first formatting/linting policy. | Reduce tooling complexity and keep style/lint fast and consistent. |
| Upstream sync process | Added sync guard tooling and explicit compatibility tracking for `common-v8` sync waves. | Keep upstream parity while avoiding accidental regressions in fork-specific work. |
| Coverage governance | Added file-level coverage gates for critical local-first paths (`Sync`, `Db`, `Worker`, `DbWorker`, etc.). | Enforce reliability on highest-risk runtime paths before merges. |
| Bun runtime adapter | Added Bun-specific worker/db adapter package (`@evolu/bun`, currently private). | Native Bun runtime support and experimentation without changing upstream APIs. |
| Test expansion | Extra tests for sync/worker/sqlite/refactor edge cases, including runtime adapter races (`DbWorker initPromise` cleanup, Relay WS lifecycle/broadcast flows). | Protect against regressions during aggressive sync and refactor work. |

## What Is Intentionally the Same

| Area | Compatibility Target |
| --- | --- |
| Public local-first API | Keep API compatibility with upstream where possible. |
| Protocol and schema direction | Follow upstream `common-v8` refactor direction and naming. |
| Core behavior | Preserve upstream semantics unless explicitly documented as fork-only behavior. |

## What Is Extra in Plan B

- Integration coverage dashboards/gates in fork workflow.
- Bun-focused adapter experiments and tests.
- SQLoot-specific maintenance/docs structure for sync operations.

## Non-Goals

- This fork is not intended to fragment protocol behavior from upstream.
- This file is not a replacement for release notes.
Loading
Loading