Skip to content

feat: land the opt-in local native sync foundation (B1) - #3899

Draft
zxch3n wants to merge 13 commits into
mainfrom
fix/native-sync-b1
Draft

zxch3n wants to merge 13 commits into
mainfrom
fix/native-sync-b1

Conversation

@zxch3n

@zxch3n zxch3n commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Problem / pressure

Land the native sync stack incrementally so the first batch can be reviewed against current main. B1 adds the local foundation behind a development-only environment switch. It does not move Session document bodies or introduce encrypted/cloud native sync.

Summary

  • Current head: 90db86cf5b45c03c6271c950bd3c446ac22b540e against the 16e6aa8c4774faa8dd1bb7faa87d854df7eb2ad8 main baseline. For fix(e2ee): keep encrypted workspaces' plaintext stores out of system backups #3885, keep both adjacent doc.ts imports and the encrypted-only backup exclusion. For chore(deps): bump Sorbet SDK to 0.1.0-alpha.41 #3900, keep main’s @sorbetai/{acp,control}@0.1.0-alpha.41 and importer ordering. Resolve only apps/cli/package.json and pnpm-lock.yaml, preserving the B1 0.2.0-next.0 dependency closure. The frozen lockfile installed successfully. A read-only merge simulation with newer main f4d989cfa found no conflicts. The evidence below is pinned to the tested pair, not the newer simulated merge.
  • Replay B1 from the approved stack in order, keeping the native SDK pinned to 0.2.0-next.0.
Source commit Replayed Scope
70cf27f955728c1dd69b1b67816a9e81e8f5a964 2e584bb78 #2902, opt-in local Workspace Meta and host
80fac28d1f04a7eaddb30b330fcc334766062ae6 c5acf6284 #2902, SDK design record
356c721d7f700e420156b02f7fff236c9d56ce51 65376f2ce #2902, published next.0 packages
a12be2f1578c5f87994730502a82846070a924db 0b08c1e5e #2905, automatic local write-back
cf540b573c55ef853f47ea4299e59f073e3ac76c b211e924b #2907, native workspace catalog
748289fd66169ada69ed67e9f835a921262cea11 ecb63336a #2908, native Machine Flocks and schedule registry
52867d937f1bb2320905d9b15df3030ef2385f11 c08410eb8 #2908, Machine Flock readiness without a legacy transport

Visual explanation

OSS local workspace startup
|- switch on -> native Meta and selected Flocks; Electron registers domain IPC
|                Session bodies continue using legacy Loro
`- switch off -> no native Electron IPC
   |- no durable marker -> open legacy; no host or engine directory
   `- durable marker -> daemon writes back to SQLite before either legacy repo opens
       |- success -> remove marker; next off start does not connect
       `- failure -> retain marker, refuse the stale workspace, retry on next start

Before / after

Before After
Local desktop and daemon always use the legacy Meta/Flock path. Default user behavior is unchanged. Only the local, non-encrypted development opt-in uses the native engine.
No native executable in OSS desktop package. Packaged host entry and one matching target-platform engine binary are present. There is no settings entry.

The comparison uses B1 90db86cf5 and main 16e6aa8c4, the pair used for the full validation. Byte counts use the same OSS target and packaging configuration on each platform. Unpacked size is the sum of regular-file sizes in the packaged application payload, with symlinks excluded.

Target Main compressed B1 compressed Delta Main unpacked B1 unpacked Delta
macOS arm64 DMG 276,790,538 285,232,284 +8,441,746 809,376,006 828,913,836 +19,537,830
Linux x64 AppImage 273,059,686 284,897,720 +11,838,034 843,586,332 872,509,989 +28,923,657
Windows x64 NSIS 236,878,888 243,811,592 +6,932,704 887,867,282 912,289,474 +24,422,192

Test plan

E2E: onboarding, desktop-windows, project-reopen, mcp-catalog

  • macOS arm64: the DMG checksum verified and the packaged app booted in both modes. Off has no native IPC or engine directory. On writes and reads Meta through IPC and receives an update after same-document navigation. Reusing the same synthetic profile across on → off → off wrote back once, consumed the marker, and did not start a host on the second off start.
  • Linux x64 AppImage and Windows x64 NSIS both built and passed off/on startup smoke from the packaged runtime. Each application includes exactly one target engine binary. No artifacts were published. Packaging job results and Windows main baseline retry.
  • The off run (pnpm check) passed static checks, typecheck and the full test runner. It also passed pnpm check:public-boundary and pnpm run docs check --base 16e6aa8c4. The on run (pnpm test:ci) passed the full suite. Both ran on isolated GitHub runners at 90db86cf5.
  • The targeted Desktop E2E and the draft static checks passed. Draft CI's required Tests aggregate alone does not establish full coverage, because the normal groups are skipped for drafts.
  • Initial flag-on full run exposed legacy CLI fixtures selecting the native path even though their source-mode harness does not produce native-repo-host.js. 5493488c7 scopes the affected fixtures to their intended legacy or cloud path, without skipping any test. Six regression suites, including the daemon’s actual native-host fixture, passed 133/133 with the flag both unset and set.
  • The initial Electron suite found that reading the switch from the engine module pulled process dependencies into the pre-ownership bundle, and that the preload's test loader could not read the new import. fb9b8aba0 moves the switch to the lightweight installation profile and the launch argument to the existing IPC contract. All 22 startup and bridge regression tests passed on the fix. The fix also removes surplus test comments without changing the repo's comment ceiling.
  • Browser boundary on 90db86cf5: Electron renderer production graph covers 8,446 module IDs in 657 chunks. The mobile WebView covers 8,586 module IDs in 662 chunks. Neither contains the engine, native client, or shared Node modules. A separate check found no engine runtime markers or bindings in the 1,072 Electron renderer JS files from the packaged Mac app.asar. The private hosted Web composition was not built.

zxch3n and others added 10 commits December 5, 2026 20:50
A separate native-repo host process owns the loro-repo-rs engine; the daemon
and Electron main each keep one connection, and renderers use finite domain
IPC through main. One observation lifecycle pages initial state and applies
changed keys. Existing LoroRepo callers keep their API through an incremental
external metadata adapter with bounded reads and read-set conditional writes.
Legacy CLI and renderer Meta migrate by LWW import with bounded coverage
verification. Off by default (LODY_NATIVE_WORKSPACE_META=1), local platform
and unencrypted workspaces only. Requires unreleased SDK changes.

Model: claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Model: claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Rust engine, client and json-patch packages (with the six platform
packages) are published at 0.2.0-next.0 from loro-repo main 98ffc19a, and the
TS loro-repo at 0.27.0; no local override is needed.

Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A legacy-mode daemon that finds the published marker merges the native Meta
room's complete export into its SQLite replica and returns the source to
legacy ownership, so turning native mode off no longer reopens a stale
catalogue and turning it on again re-imports edits made meanwhile.

Model: claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The workspace catalog Flock (`<ws>:wf:workspace`) joins the native switch.
Daemon and renderer repos keep their wasm Flock replicas through loro-repo's
external Flock owner: loaded from the room's raw export, updated by changes
that carry clocks, committed on the existing persistence barriers, and never
written to storage or the local data plane. The renderer reaches it through
main, which admits only the workspace's owned ids. Migration and write-back
use the same room-level step as Meta; the observation lifecycle gains a
register mode instead of a second state machine.

Model: claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every machine Flock and the schedule registry join the workspace catalog as
natively owned named Flock documents. Ownership becomes a predicate; migration
imports each owned document in a legacy replica's inventory, and write-back
walks the Flock registry so a machine first seen in native mode returns too.

Model: claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With native Workspace Meta the engine owns a local workspace's Machine
Flocks: loro-repo persists a write to the owner and reports `no-route`, so
the renderer retried a remote sync forever and never confirmed the rows. The
landing then kept a removed project selected, because a missing project stays
`pending` until the Machine Flock is confirmed. Encrypted workspaces keep the
old rule: their engine state does not prove the cloud rows have arrived.

Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Packaged Electron cannot load workspace TypeScript behind node_modules. Keep the platform runtime in the local main bundle.

Model: gpt-6
Do not register native IPC or open the engine for a never-enabled profile. Keep the rollback marker authoritative across automatic write-back and a failed startup. Retain the browser boundary and the built-desktop Meta readiness fixes needed by B1.

Model: gpt-6
Preserve both the local native and encrypted storage contracts in the shared daemon initialization file.

Model: gpt-6
Read the switch in the installation profile and pass the preload argument through the existing Electron IPC contract. Preserve existing lease and preload tests without broadening their imports.

Model: gpt-6.2-sol
Keep Sorbet alpha.41 and main’s workspace graph. Restore only the B1 next.0 native dependency closure and keep the upstream shared importer ordering.

Model: gpt-6.2-sol

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant