remove plans
- Commit
6ac6b2d89bbd32a9f8e715f1b2d6af7505441906- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-12 22:09 UTC (3 months ago)
- Parents
9ffbfb9
Diff
BRAVE_SHIELDS_PLAN.plan.md
diff --git a/BRAVE_SHIELDS_PLAN.plan.md b/BRAVE_SHIELDS_PLAN.plan.mddeleted file mode 100644index 375b7ac423..0000000000--- a/BRAVE_SHIELDS_PLAN.plan.md+++ /dev/null@@ -1,177 +0,0 @@-# Brave Shields for `:web`--Port Brave's four protection subsystems into the existing WebView browser at-`/Users/vayun/Documents/Modern-Apps/web`, keeping the `AndroidView` + `android.webkit.WebView`-architecture exactly as it is.--**Decisions locked in:** Brave's real `adblock-rust` engine via JNI · bundle-only filter lists ·-global toggles + per-site shields panel with allowlist and block counter · **Aggressive** defaults.-------## Goal--Replace the current 10-entry hardcoded blocklist-(`web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.kt:159-171`) with the actual Brave-Shields stack:--| Shield | Mechanism in a WebView |-|---|---|-| Network ad/tracker blocking | `adblock` crate in `shouldInterceptRequest` |-| Cosmetic filtering | `url_cosmetic_resources` + `hidden_class_id_selectors`, injected at document start |-| Fingerprinting protection | Farbling JS injected at document start, per-session × per-eTLD+1 seed |-| URL cleaning + HTTPS upgrade | `shouldOverrideUrlLoading` + adblock `$removeparam` rewrites |-------## Feasibility already verified--- `adblock` **v0.13.2** resolves and **compiles clean for `aarch64-linux-android` in 24s**- (61 crates, `default-features = false`, features `embedded-domain-resolver` + `full-regex-handling`).-- Required API confirmed present in the crate source: `Engine::new_with_list_text`,- `use_resources`, `check_network_request(&Request) -> BlockerResult`,- `url_cosmetic_resources(url) -> UrlSpecificResources`, `hidden_class_id_selectors`,- `serialize`/`deserialize`.-- `rustNativeLib(crate)` in `build-logic/src/main/kotlin/RustNative.kt` makes wiring a one-liner;- `pdf/build.gradle.kts:18-32` is the copy-paste precedent.-- ⚠️ **Pre-existing, unrelated env bug:** plain `cargo build --target aarch64-linux-android` fails- with `can't find crate for core` for **every** Rust module in this repo (verified against- `library/jni-http`). Setting `RUSTC=$HOME/.cargo/bin/rustc` fixes it. Will add that one line to- `RustNative.kt` so all 15 native modules build again.-------## Phase 1 — Filter list assets--Bundle-only, following the repo's established "generator script in `scripts/` + brotli asset"-convention (`scripts/wordmaker/generate_dictionary_assets.py`, `libs.brotli.dec` is already in the-version catalog at `gradle/libs.versions.toml:223`).--- **New** `scripts/generate_shields_lists.py` — developer-run, offline. Fetches EasyList,- EasyPrivacy, Brave's default + unbreak lists and uBO's `resources.json` (scriptlet/redirect- bodies), strips comments, concatenates, brotli-compresses.-- **New assets** (checked in):- - `web/src/main/assets/shields/filters.txt.br` (~700 KB from ~4.5 MB raw)- - `web/src/main/assets/shields/resources.json.br`- - `web/src/main/assets/shields/farble.js` (Phase 5, hand-written)--## Phase 2 — Rust engine crate--- **New** `web/src/main/rust/` → crate `web_shields`, `crate-type = ["cdylib"]`.- Deps: `jni.workspace`, `serde_json.workspace`, `adblock 0.13.2` (features as verified above).-- Register in root `Cargo.toml` `[workspace] members` + add `adblock` to `[workspace.dependencies]`.-- `src/lib.rs` JNI surface (handle = `Box::into_raw` of `Engine`, which is `Sync`):- - `nativeCreate(filters, resourcesJson) -> jlong`- - `nativeCreateFromCache(bytes) -> jlong` / `nativeSerialize(handle) -> ByteArray`- - `nativeCheck(handle, url, sourceUrl, requestType) -> String` (JSON: matched / important /- exception / redirect body / rewritten_url) — one JNI hop per request- - `nativeCosmeticResources(handle, url) -> String`- - `nativeHiddenClassIdSelectors(handle, classes, ids, exceptions) -> String`- - `nativeDestroy(handle)`-- `web/build.gradle.kts`: add `rustNativeLib("web_shields")`, the `androidComponents` jniLibs block- (mirroring `pdf`), and `implementation(libs.brotli.dec)`.--## Phase 3 — Kotlin bridge--- **New** `web/src/main/java/com/vayunmathur/web/shields/ShieldsEngine.kt` — process singleton.- `load(context)` on `Dispatchers.IO`: deserialize `filesDir/shields/engine.dat` if its version tag- matches the bundled asset, else parse the brotli assets and write the serialized cache.- Exposes `check(...)`, `cosmetic(url)`, and a `ready` flag.-- Fail-open while not ready — `shouldInterceptRequest` must never block the render thread.--## Phase 4 — Network shield--- **New** `web/src/main/java/com/vayunmathur/web/shields/ShieldsWebViewClient.kt`, an open- `WebViewClient` subclass that tracks the current main-frame URL (needed because- `WebResourceRequest` carries no initiator) and implements `shouldInterceptRequest`:- resource type from `Sec-Fetch-Dest` → `Accept` → extension; per-site allowlist check; blocked →- empty response with a *type-appropriate* MIME (empty JS, 1×1 GIF for images — `text/plain` for- everything, as today, itself breaks pages); `$redirect` → serve the uBO resource body;- increment the per-tab counter.-- Wire into **both** `WebViewBrowser.kt` *and* `PwaActivity.kt` (which has **no**- `shouldInterceptRequest` today).-- Delete the `adHosts` set and the dead `WebViewModel.adBlockEnabled` (`WebViewModel.kt:93-94`),- which the interceptor never consulted.--## Phase 5 — Cosmetic filtering--- Inject via `WebViewCompat.addDocumentStartJavaScript` when- `WebViewFeature.DOCUMENT_START_SCRIPT` is supported, else fall back to `onPageStarted` +- `evaluateJavascript`.-- Pass 1: URL-specific hide selectors → `<style>` + Brave's `injected_script`.-- Pass 2 (Brave's model): a `MutationObserver` collects new class/id attributes and reports them- through `WebViewCompat.addWebMessageListener` → `hidden_class_id_selectors` → inject more CSS.--## Phase 6 — Fingerprinting protection (Aggressive)--`web/src/main/assets/shields/farble.js`, prefixed at injection with a per-session × per-eTLD+1-seed so values are stable within a page but differ across sites and restarts. Farbles canvas-(`toDataURL`/`getImageData`/`toBlob` LSBs), WebGL (`getParameter` unmasked vendor/renderer,-`readPixels`), AudioContext, `measureText` font metrics, `hardwareConcurrency`, `deviceMemory`,-empty `plugins`/`mimeTypes`, `navigator.languages`. Aggressive additionally forces UTC-`getTimezoneOffset`/`Intl` and disables `RTCPeerConnection` (local-IP leak).--## Phase 7 — URL cleaning + HTTPS upgrade--- **New** `web/src/main/java/com/vayunmathur/web/shields/UrlCleaner.kt` — pure Kotlin, no- `android.net.Uri`, so it unit-tests on the JVM. Strips Brave's tracking-param list- (`utm_*`, `fbclid`, `gclid`, `msclkid`, `igshid`, `twclid`, `yclid`, `dclid`, `mc_eid`, …);- adblock `$removeparam` rules supply the rest via `rewritten_url`.-- HTTPS upgrade in `shouldOverrideUrlLoading`; Aggressive = HTTPS-only (block rather than- silently downgrade) + `mixedContentMode = MIXED_CONTENT_NEVER_ALLOW`.--## Phase 8 — Settings, state, persistence--- `ShieldLevel` enum (`OFF` / `STANDARD` / `AGGRESSIVE`) + `ShieldsSettings` in `web/util/`.-- Globals in `WebViewModel` through the existing `web_prefs` / `persistPrefs()` pattern- (`WebViewModel.kt:38-44, 675-688`); incognito windows persist nothing.-- Per-site overrides: new Room entity `ShieldSetting(host, …)` + `MIGRATION_2_3` in- `web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt` (currently `version = 2`).-- Per-tab blocked counters in the VM, reset on main-frame navigation.--## Phase 9 — UI--- Add `IconShield()` to `library/ui/.../Icons.kt` — CONTRIBUTING.md forbids `Icon()` /- `painterResource` / direct `androidx.compose.material.icons` imports in app modules.-- Shield button with blocked count in `BrowserChrome` actions (`BrowserPage.kt:575`), using the- existing `Surface`+`Text` chip idiom since `:library:ui` exports `BadgedBox` but **not** `Badge`.-- **New** `ShieldsPanel` as a `ModalBottomSheet` (exported by `:library:ui`): per-site master- toggle, per-shield switches, blocked breakdown, reload-to-apply.-- `SettingsPage.kt:124-129`: replace the dead "Ad-tracker blocking — Always on" row with a real- Shields section + a `Route.Shields` page for per-site exceptions.-- All copy into `web/src/main/res/values/strings.xml` via `stringResource`.--## Phase 10 — Tests--`web/src/test/` does not exist yet; `kotlin.test` + JUnit4 are already wired for every app module-by `common-conventions-app.gradle.kts:195-196`, so **no Gradle change is needed**.--- `UrlCleanerTest.kt` — param stripping, HTTPS upgrade decisions-- `ResourceTypeTest.kt` — `Sec-Fetch-Dest`/`Accept`/extension → adblock `RequestType`-- `ShieldsSettingsTest.kt` — level → effective-shield resolution, per-site override precedence-------## Risks--1. **`shouldInterceptRequest` is hot and off-thread.** Engine calls must be lock-free on the read- path and fail-open before load completes.-2. **Aggressive farbling breaks sites.** The per-site shields panel is the escape hatch; that is- why Phase 9 is not optional.-3. **Two WebView hosts drift.** `WebViewBrowser.kt` and `PwaActivity.kt` already have divergent- copies of `applySettings`; Phase 4 extracts the shared client so shields can't be wired to only one.-4. **Cargo env bug** must be fixed in `RustNative.kt` first or nothing native builds.--## Files touched--**New:** `web/src/main/rust/{Cargo.toml,src/lib.rs}` · `web/src/main/assets/shields/*` ·-`web/src/main/java/com/vayunmathur/web/shields/{ShieldsEngine,ShieldsWebViewClient,UrlCleaner,ShieldsSettings}.kt` ·-`web/src/main/java/com/vayunmathur/web/ui/ShieldsPanel.kt` · `web/src/test/...` ·-`scripts/generate_shields_lists.py`--**Modified:** `Cargo.toml` · `build-logic/src/main/kotlin/RustNative.kt` · `web/build.gradle.kts` ·-`web/src/main/java/com/vayunmathur/web/ui/{WebViewBrowser,BrowserPage,SettingsPage}.kt` ·-`web/src/main/java/com/vayunmathur/web/PwaActivity.kt` ·-`web/src/main/java/com/vayunmathur/web/util/WebViewModel.kt` ·-`web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt` · `web/src/main/MainActivity.kt` (route) ·-`web/src/main/res/values/strings.xml` · `library/ui/.../Icons.kt`
NETWORK_CAPTURE_PLAN.md
diff --git a/NETWORK_CAPTURE_PLAN.md b/NETWORK_CAPTURE_PLAN.mddeleted file mode 100644index a1b98882c6..0000000000--- a/NETWORK_CAPTURE_PLAN.md+++ /dev/null@@ -1,48 +0,0 @@-# Network Capture App Plan for Google Voice SIP Analysis--## Goal-Build a simple Android VPN service app that captures network packets and filters for SIP traffic to/from Google Voice servers, to discover the actual SIP server IP addresses and credential format used by the official Google Voice app.--## Approach--Android's VpnService API allows creating a local VPN that intercepts all device traffic without root. We'll build a minimal capture app that:-1. Creates VpnService to intercept packets-2. Filters for SIP traffic (UDP/TCP ports 5060, 5061, 5062 + hostnames containing sip.google.com, voice.sip, pbx.voice)-3. Logs SIP packets in human-readable format to logcat and/or file-4. User runs capture, opens Google Voice app, makes test call, stops capture, we analyze logs--## Implementation--### Module structure-- New module `:netcapture` in Modern-Apps repo-- Minimal UI: Start/Stop buttons + log display-- VpnService implementation using Android's built-in VPN API (no root, no custom CA needed for SIP since it's plaintext protocol not HTTPS)--### Key files to create-- `netcapture/src/main/java/com/vayunmathur/netcapture/MainActivity.kt` — UI-- `netcapture/src/main/java/com/vayunmathur/netcapture/PacketCaptureVpnService.kt` — VpnService implementation-- `netcapture/src/main/java/com/vayunmathur/netcapture/PacketParser.kt` — Parse IP/UDP/TCP headers, extract SIP payload-- `netcapture/src/main/AndroidManifest.xml` — VpnService declaration + BIND_VPN_SERVICE permission-- `netcapture/build.gradle.kts` — module config--### What we'll capture-- SIP REGISTER requests/responses (will show username, realm, nonce, server IP)-- SIP INVITE requests (for outgoing calls)-- DNS queries for voice.sip.google.com (to see what IPs it resolves to, if any)-- Any HTTPS API calls to GetSIPRegisterInfo endpoint (to confirm our reverse-engineered structure matches)--### Expected output format in logcat-```-[SIP] 192.168.0.135:45678 -> 142.250.x.x:5061 REGISTER sip:voice.sip.google.com SIP/2.0-[SIP] Via: SIP/2.0/TLS ...-[SIP] From: <sip:+1213... @voice.sip.google.com>;tag=...-[SIP] To: <sip:+1213... @voice.sip.google.com>-[SIP] Authorization: Digest username="...", realm="...", nonce="...", uri="...", response="..."-```--This will definitively reveal:-- Actual SIP server IP address (bypassing the DNS NXDOMAIN issue — official app must resolve it somehow)-- SIP username format-- SIP realm value-- Auth scheme (Digest vs Bearer)-- Whether it's SIP over UDP, TCP, or TLS
office/BACKEND_DESIGN.md
diff --git a/office/BACKEND_DESIGN.md b/office/BACKEND_DESIGN.mddeleted file mode 100644index be965e0f85..0000000000--- a/office/BACKEND_DESIGN.md+++ /dev/null@@ -1,209 +0,0 @@-# Office Backend & Collaboration — Design Notes--> How we *would* build the server-dependent features (real-time collaboration, cloud sync,-> version history, sharing) for the Office module. This is a design/architecture doc, not-> shipped code — those features need a backend service + device testing that can't be built or-> verified purely in this repo. It maps each idea onto the app's **current** architecture.--## 0. The architectural constraint we start from--Today every edit does this (`OfficeViewModel.updateDocument`):--1. build a **new immutable `OdfDocument`** via `.copy(...)`-2. push the old doc onto an undo stack-3. `_state.value = ViewState.Loaded(newDoc)` → Compose recomposes from scratch-4. mark dirty; autosave writes the **whole** `.odt/.ods/.odp` via `OdfWriter`--This is a **snapshot/whole-document** model. It's great for local editing + undo, but it's the-wrong granularity for collaboration and efficient sync, because we never produce *operations* —-we only produce new whole-document states. **Every backend feature below hinges on introducing an-operation/delta layer** between the UI intent and `updateDocument`. That refactor is the keystone.-------## 1. Operation layer (prerequisite for everything)--Introduce a small algebra of **document operations** that (a) can be applied to an `OdfDocument`-to produce the next one, and (b) can be serialized, sent over the wire, transformed, and inverted.--```-sealed interface OdfOp {- // text- data class InsertText(val path: BlockPath, val offset: Int, val text: String, val style: SpanStyle?)- data class DeleteText(val path: BlockPath, val start: Int, val end: Int)- data class SetSpanStyle(val path: BlockPath, val start: Int, val end: Int, val patch: SpanStylePatch)- data class SetParaProp(val path: BlockPath, val patch: ParaPropPatch)- data class InsertBlock(val index: Int, val block: OdfContentBlock)- data class DeleteBlock(val index: Int)- data class MoveBlock(val from: Int, val to: Int)- // sheet- data class SetCell(val sheet: Int, val row: Int, val col: Int, val patch: CellPatch)- data class ResizeCol(val sheet: Int, val col: Int, val px: Float?)- // slide- data class SetElementBounds(val slide: Int, val el: Int, val x: Float, val y: Float, val w: Float, val h: Float)- ...-}-fun OdfDocument.apply(op: OdfOp): OdfDocument // pure-fun OdfOp.invert(before: OdfDocument): OdfOp // for undo + rollback-```--- `BlockPath` addresses a location stably (see §2 on why plain indices break under concurrency).-- The existing ~120 `OfficeViewModel` mutators become **thin wrappers that emit ops** and call a- single `dispatch(op)` that (1) applies locally, (2) records for undo, (3) hands to the sync- engine. Undo/redo becomes op-inversion instead of snapshot stacks (smaller, and *mergeable* with- remote ops).-- Autosave/export are unchanged (still serialize the current snapshot); the ops are an *additional*- stream, not a replacement for the on-disk ODF.--This is a big but mechanical refactor and is independently valuable (smaller undo, telemetry,-scripting/macros later).-------## 2. Real-time collaboration--### 2.1 CRDT vs OT — choice--Two families solve concurrent editing:--- **OT (Operational Transform)** — Google-Docs style. Central server transforms each op against- concurrent ops. Simple ops, but the transform matrix is subtle and you *must* have a server in- the loop (hard to do peer-to-peer / offline-first).-- **CRDT (Conflict-free Replicated Data Type)** — ops/state merge deterministically without a- central authority; naturally offline-first and P2P-capable. Cost: metadata overhead and trickier- "intention preservation" for rich structure.--**Recommendation: CRDT**, because the app is offline-first (local `.odt` files, autosave) and-Android clients are frequently disconnected. Use a proven library rather than rolling our own:-**Yjs** (via a Kotlin/JNI binding or a Kotlin port) or **Automerge** (Rust core → `automerge-rs`-with a Kotlin FFI). For text specifically, Yjs's `Y.Text` (a sequence CRDT with formatting marks)-maps almost 1:1 onto our paragraph/span model.--### 2.2 Mapping OdfDocument → CRDT--The document becomes a CRDT tree instead of an immutable snapshot:--- `content: Y.Array<Block>` — each block is a `Y.Map`.-- Paragraph block → `{ type, style, spans: Y.Text }` where `Y.Text` carries character-level- formatting as marks (bold/italic/link/color…) — exactly our `OdfSpan` attributes.-- Table → nested `Y.Array` of rows → `Y.Array` of cells (`Y.Text`).-- Spreadsheet → `Y.Map` keyed by `"$sheet:$row:$col"` (sparse; matches our sparse grid) plus- `Y.Map`s for column widths / merges / floating.-- Slide element → `Y.Map` of geometry + `Y.Text`.--**This replaces `BlockPath`-by-index** (§1) with CRDT-stable identifiers, which is the real reason-CRDT beats hand-rolled OT here: indices shift under concurrent inserts; CRDT positions don't.--The Compose layer stays: on any CRDT update event we **materialize a plain `OdfDocument`** from the-CRDT and push it through the same `ViewState.Loaded(doc)` path — so `DocumentViews`/`OfficeBottomBar`-don't change at all. Local edits go: UI intent → mutate CRDT → CRDT emits update → re-materialize →-recompose. The materialize step can be incremental later; start with full rebuild (we already do-that per keystroke today, so it's no worse).--### 2.3 Transport & topology--```-Client (Android) <—— WebSocket ——> Sync service <——> Doc store (per-doc op log + snapshots)- │ Yjs doc + local IndexedDB/Room persistence- └── awareness channel (presence: cursors, selection, name, color)-```--- **Sync service**: stateless relay + persistence of the CRDT update stream per document. A room =- one document id. It appends encrypted update blobs and periodically compacts to a snapshot.- Off-the-shelf option: `y-websocket` server, or `Hocuspocus` (adds auth hooks, persistence,- webhooks). We host it (Tupperware/Twine-style container) behind auth.-- **Presence/awareness**: ephemeral (not persisted) — remote carets and selections. Render as- colored overlays; we already track selection as hoisted indices, so add a `remoteSelections:- List<RemoteCaret>` to the view state and draw them in `ContinuousParagraphEditor` /- `FloatingElementLayer`.-- **Offline**: CRDT updates queue in Room while offline; on reconnect the client sends its pending- updates and receives missed ones — merge is automatic and conflict-free. No "resolve conflicts"- dialog needed for concurrent edits (that's the whole point of CRDT).--### 2.4 What's hard / gotchas--- **ODF ⇄ CRDT fidelity**: our model has rich, evolving fields; the CRDT schema must cover them or- edits to unmodeled fields get lost on merge. Mitigate by versioning the CRDT schema and keeping- a "opaque preserved blob" for unsupported parts (we already do this for imported ODF via- source-package copy).-- **Large binary media** (images) don't belong in the CRDT — store them content-addressed- (sha256) in object storage; the CRDT holds only the hash. Matches our `images: Map<path, bytes>`.-- **Formula recalculation** must run locally after each merged change (we already have- `OdfFormulaEngine`); recalc is deterministic so all clients converge.-- **Undo across users**: undo must only revert *your* ops (Yjs `UndoManager` with a tracked- origin) — otherwise you undo a collaborator's work. Wire our undo to the CRDT UndoManager.-------## 3. Cloud sync & storage (documents-at-rest)--Even without live collaboration, "my files everywhere":--- **Model**: each document has a server id, an owner, and a current version. Storage = object store- (S3-style) holding the serialized `.odt/.ods/.odp` (reuse `OdfWriter`) + a thumbnail + metadata- row in a DB.-- **Client**: a `SyncRepository` sitting beside `OfficeViewModel`. On `save()` (already exists), if- the doc is cloud-backed, upload; on open, download. Background `WorkManager` job reconciles.-- **Conflict resolution WITHOUT live collab** (two devices edit offline): can't auto-merge whole- ODF safely. Options in increasing sophistication:- 1. **Last-writer-wins + keep-a-copy**: on version mismatch, upload as `Name (conflicted copy)`- and let the user pick — simple, never loses data. Ship this first.- 2. **3-way merge** using the operation log from §1 (rebase local ops onto the server's newer- base). Requires the op layer; degrades to (1) when ops aren't available.- 3. **Always-on CRDT** (§2) makes this a non-issue.-- **ETags/versions**: conditional PUT (If-Match) to detect races; server rejects stale writes →- client falls back to conflict copy.--## 4. Version history--- Cheap version: the sync service already stores periodic **snapshots** (ODF blobs) + the op/update- log. A "History" screen lists snapshots (timestamp, author, thumbnail) and lets you preview/- restore (restore = new op that sets state to that snapshot, so it's itself undoable).-- With the op layer, we can show **granular history** ("Alice bolded paragraph 3") and- named versions, like Docs.--## 5. Autosave & local durability (mostly already here)--- Autosave loop exists (`setAutoSave` → `save()`), and undo/redo. Add: **crash-safe journaling** —- append each op (§1) to a Room-backed WAL so an unsaved session survives a process death, and- replay on next open. This is local-only and buildable/testable now (no server), and is a good- first concrete step toward the op layer.--## 6. Auth, sharing, permissions--- **Auth**: OIDC (Google/Apple/enterprise SSO). Client holds a token; sync WebSocket + REST are- authenticated per request; the sync room enforces per-doc ACL on connect.-- **Sharing model**: per-document ACL — `owner / editor / commenter / viewer`. Map to op-level- gating: a `commenter` may only emit comment/annotation ops (we already have comment ops); a- `viewer` emits none and never gets an editable `ViewState`. Share via signed link (role encoded- + expiry) or explicit user grants.-- **Comments as first-class**: our comment model exists but is paragraph-anchored; for real review- workflows, anchor comments to CRDT ranges (relative positions) so they stay attached as text- moves, and add threads/replies/resolve (server stores the thread; client renders the existing- Comments panel).-------## 7. Incremental rollout (each step ships value on its own)--1. **Op layer + WAL journaling** (local only, fully testable here) — smaller undo, crash recovery,- foundation for the rest.-2. **Cloud sync with LWW + conflict-copy** — "files everywhere", low risk.-3. **Version history** from stored snapshots.-4. **CRDT swap-in** for the document model (materialize → same Compose UI) — offline-first merge.-5. **Live presence + real-time editing** over WebSocket (awareness cursors, then shared editing).-6. **Sharing/permissions + review (threaded comments)**.--Steps 1 and parts of 5 (rendering remote carets) are implementable/verifiable in this repo; steps-2–6 need the sync service + auth backend and real multi-device testing, which is why they're a-design here rather than code.--## 8. Rough server stack--- Sync: Kotlin/Ktor or Node **Hocuspocus** for the CRDT room + persistence hooks.-- Store: Postgres (metadata/ACL/versions) + S3-compatible object store (ODF blobs, media by hash).-- Realtime: WebSocket (sticky by doc id) behind a load balancer; Redis pub/sub to fan out rooms- across instances.-- Auth: OIDC provider + short-lived JWTs; per-room authorization check on connect.-- Media: content-addressed, deduped, served via signed URLs.-```