Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a75210c
fix(collab,sync): journal-fenced CRDT, multi-hunk diff3, and 8-peer e…
isac322 Nov 11, 2026
fc7362f
fix(webapp): preserve non-colliding peer edits in VisualEdit word con…
isac322 Nov 11, 2026
34193d0
fix(webapp): retry failed conflict-copy PUTs and park exit clashes se…
isac322 Nov 11, 2026
88a19c4
fix(webapp): make client and room conflict-copy writes create-only
isac322 Nov 11, 2026
6a088a6
fix(webapp): send emptied buffers on exit and adopt bfcache checkpoints
isac322 Nov 11, 2026
8942b1b
fix(webapp): validate .json/.jsonl three-way merges on the client
isac322 Nov 11, 2026
a94090b
fix(webapp): check shrink synchronously on explicit save and after Do…
isac322 Nov 11, 2026
87c6406
fix(webapp): await server shrink verdict before Done leaves
isac322 Nov 11, 2026
9fe7bba
fix(webapp): await saveNow settlement on Done without fixed timeout
isac322 Nov 11, 2026
a14f2a4
fix(webapp): drain concurrent edits in saveNow and keep editor open o…
isac322 Nov 11, 2026
647e5fb
fix(webapp): drain VisualEdit iframe patches via bd-edit:flush ACK be…
isac322 Nov 11, 2026
228a0b1
fix(webapp): lock VisualEdit iframe during Done save and unlock on stay
isac322 Nov 11, 2026
255a89e
fix(webapp): guard Edit source swap during Done save and re-check act…
isac322 Nov 11, 2026
ad0cb0d
fix(webapp): drain and lock VisualEdit iframe before staging-to-live …
isac322 Nov 11, 2026
f1ba6e1
fix(webapp): splice anchored VisualEdit patches synchronously before …
isac322 Nov 11, 2026
6a39d02
fix(webapp): beacon unacked VisualEdit iframe patches across opaque s…
isac322 Nov 11, 2026
84f31d6
fix(desktop,webapp): proxy capability beacon without originGuard and …
isac322 Nov 11, 2026
e2bcc8b
fix(webapp): track per-span exact-seq acknowledgements for VisualEdit…
isac322 Nov 11, 2026
03fa86f
fix(webapp): run VisualEdit exit save in same-origin worker without i…
isac322 Nov 11, 2026
60d1a24
fix(webapp): gate VisualEdit exit worker on trusted parent interactio…
isac322 Nov 11, 2026
9416295
fix(webapp): seal VisualEdit iframe channel in virgin realm and re-ar…
isac322 Nov 11, 2026
50bfccc
fix(webapp): lock VisualEdit stamped ranges and block script writes t…
isac322 Nov 11, 2026
ac567db
fix(webapp): verify trusted InputEvent text delta in dispatchTransact…
isac322 Nov 11, 2026
1ef9db8
fix(webapp): validate deletions and mark attributes against trusted u…
isac322 Nov 11, 2026
8a137f4
fix(webapp): check positional mark sets and NamedNodeMap removals on …
isac322 Nov 11, 2026
2b71087
fix(webapp): isolate VisualEdit ProseMirror mount inside a closed sha…
isac322 Nov 11, 2026
440a5ed
fix(webapp): carry page stylesheets into VisualEdit closed shadow root
isac322 Nov 11, 2026
b2098d7
fix(webapp): mirror ancestor selector chain inside VisualEdit closed …
isac322 Nov 11, 2026
10a5961
fix(webapp): freeze DOM prototypes before page scripts and whitelist …
isac322 Nov 11, 2026
0a6851e
fix(webapp): isolate VisualEdit exit-span state in worker realm and u…
isac322 Nov 11, 2026
3af174b
fix(webapp): verify bound element innerHTML before mounting VisualEdi…
isac322 Nov 11, 2026
4d98490
fix(webapp): lock JS intrinsic methods and deep-freeze RawInline mark…
isac322 Nov 11, 2026
58f546a
fix(webapp): confirm exit-worker span acks only after landed response…
isac322 Nov 11, 2026
d85c0c7
fix(webapp): keep per-span ackedSeq monotonic across late exit-save r…
isac322 Nov 11, 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
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ Notable changes per release. Format loosely follows
minor versions may ship breaking changes (see [SemVer §4](https://semver.org/#spec-item-4)).
## Unreleased

## v0.18.10 — 2026-11-11

**Update your devices and self-hosted hubs** for the co-editing and merge
fixes; running daemons switch over the first time the updated `bdrive` runs.
Client wire and local volume on-disk formats remain backward-compatible, and
v0.18.10 hubs read the bare-sha `ydoc/head/<path>` records older hubs wrote.
**Upgrade every hub process that shares a storage root together:** v0.18.10
hubs write `ydoc/head/<path>` as JSON (`{sha, win}`), which a v0.18.9 or
earlier hub process cannot read. During a mixed-version rollout or a rollback,
that older process skips the newest stored room state and falls back to the
per-blob CRDT history (`ydoc/<sha>`) or, when none matches, to fresh file
bytes, so do not run v0.18.9 and v0.18.10 side by side on one storage root.

- **Co-editing rooms seed from the newest stored state across hub processes.** `ydoc/head/<path>` now stores `{sha, win}`, where `win` is the `winKey` of the journal op that produced the stored room state. A head write with an older `win` is refused, so an older fold in any process can no longer move the head backwards, and a room whose file no longer matches the head seeds from the file. `knows()` merges the other state into a scratch copy and checks whether anything changed, so stored histories that contain deletions compare correctly. Empty rooms stay loaded for 2 minutes (`collabRoomIdleTimeout`), and the Redis relay keeps 30 minutes of updates (`StreamRetention`, up from ygo's 60-second default); a failed snapshot republishes the room's full state into that window and retries.
- **Outside writes merge into live rooms without losing concurrent typing.** `moveDocLive` computes the change on a private copy of one atomic room snapshot and applies only the resulting CRDT item delta, so keystrokes that arrive during the merge stay in place instead of shifting by stale character offsets.
- **`POST /api/p/<id>/ycollab/sync` merges browser edits into a room over HTTP.** A browser without a connected socket sends its Yjs state, or its text with the base it started from; `peek` reads the room without writing. The hub answers `ok` only after storage holds the edit, waiting up to 8 seconds (`ycollabSyncDurableWait`), including for the lease holder in another process; otherwise it returns `503` and the browser keeps its edits.
- **Concurrent text edits merge per hunk and per word.** `internal/textmerge` and its browser port `frontend/src/lib/merge3.ts` diff each side with Myers O(ND), so edits in different parts of a file merge as separate hunks (diff3). Two edits to the same line merge word by word when they change different words, and insertions at the same point are ordered by content, so `merge(base, a, b)` equals `merge(base, b, a)`. The merge now runs in four places: `PUT /api/p/<id>/upload/content` with a stale `If-Match` merges base, head and incoming bytes instead of returning `409` (text only, up to 4 MiB; `X-Bdrive-No-Merge` opts out); MCP `write` and `edit` given an outdated sha merge from that version; live room reconciliation; and `internal/syncer` before it writes a conflict copy. Two different rewrites of the same lines or words still conflict.
- **Hub writes record their base, and devices skip redundant merges.** Conditional hub writes record the version they were built on in `Op.Base`. The sync engine merges a losing op against the op that won, and when the result equals the winner's content (another device or the hub already merged both sides), it fast-forwards and writes no new op.
- **Browser co-editing keeps edits through slow joins, saves and most tab closes.** When the room has not answered after 2.5 seconds, the editor mounts a staging buffer (`onStalled`) and checkpoints it into the room as text over `ycollab/sync`, then merges it three ways when the socket connects. Previously the editor gave up on the room after 8 seconds and saved its own copy for the rest of the session. `save()` is single-flight. `Mod-s` saves immediately, and Done saves every edit, including any typed during the save, before leaving, and stays in the editor if the save fails or opens a shrink confirmation. `pagehide` sends pending edits with `keepalive` when the encoded HTTP request body is at most 60,000 bytes (`KEEPALIVE_MAX_BYTES`, below the browser's 64 KiB in-flight `keepalive` limit); a larger body goes out as a regular `fetch`, which the browser may cancel during unload, and delivery is never guaranteed once the browser tears the page down. `pageshow` resets the exit-send guard, so a page restored from the back/forward cache can flush again on a later close. Room snapshots that arrive after a save are recognized as the room's own history (`seenRoomTexts`), which stops false `#peer-wrote` banners when eight or more people edit one meeting note. `VisualEdit` applies an element edit as the smallest splice inside that element.
- **`VisualEdit` flushes unacknowledged iframe edits through a same-origin exit worker when the tab closes.** The editing iframe stays `sandbox="allow-scripts"` and is never given a session, token or URL. `VisualEdit` starts a dedicated Web Worker on the app's origin (`editexit.worker.ts`), keeps it current with the rendered source, the anchored ranges and what the file and document hold after every save, and hands the iframe only one end of a `MessageChannel` (`bd-edit:port`). The iframe streams each edit to the worker as it happens (`bd-edit:span`) and keeps no record of its own; the app tells the worker directly which patches it applied (`ack`), so all span and acknowledgement state lives in the worker. When the iframe unloads it posts `bd-edit:exit`, and the worker saves whatever is still unacknowledged. This exit save is best-effort and runs only once the worker has started and been armed with the anchored render. The worker splices only anchored, script-free spans onto the render, merges the result three ways with the current document, and saves it with the app's own cookie: `POST /api/p/<id>/ycollab/sync` on a hub or `bdrive desktop`, or `PUT upload/content` on the latest `If-Match` in a plain folder, so it also works after earlier auto-saves. A same-word clash parks a conflict copy, an unconfirmed sharp shrink is not sent, and delivery is still subject to the browser's teardown limits (`keepalive` up to 60,000 bytes).
- **The `VisualEdit` iframe talks to the app only over a sealed channel, and the exit worker re-arms after a back/forward-cache restore.** The editable view now injects `/inline-edit.js` synchronously before any script in the synced HTML file, so it captures the browser's own `MessageChannel`, `MessagePort` methods and `Event.isTrusted`, uncurries the `WeakMap`, `Map` and `Set` builtins it uses, and freezes the DOM, Event, Range, Selection and geometry prototypes before page code can replace them. It opens a private `MessageChannel` and sends `bd-edit:hello` with one port to the app once; every later editor message (ready, patch, port, flush, unlock) uses that channel instead of `window.postMessage`, and an editor opens or changes only on a trusted user event. Pasted formatting is kept only from the trusted clipboard's `text/html`. When a page comes back from the back/forward cache, `VisualEdit` sends the exit worker `rearm` with a fresh port, so an unacknowledged edit made after the restore is still saved when the tab closes again.
- **`VisualEdit` edits only the ranges the hub stamped, and page scripts cannot write into an open editor.** The bootstrap tag now also carries `data-src-ranges`, the stamped `start,end` list the hub measured. `inline-edit.js` reads and removes its `data-src-*` attributes at load, locks `data-bd-src` against page-script writes, and binds each stamped element once, refusing a duplicate or unstamped range. A page script that changes the element being edited (its own key or input listener, `execCommand`, any DOM write) is refused, and the frame reports `bd-edit:clobbered` instead of saving. Before anchoring a range or arming the exit worker, `VisualEdit` checks that the element's initial HTML matches the source slice, comparing both as an inert `<template>` parses them.
- **The `VisualEdit` editor runs inside a closed shadow root.** `inline-edit.js` mounts the editor on an element inside a closed shadow root (`attachShadow({ mode: "closed" })`, captured at load) attached to a `<span data-bd-shadow>` inside the element being edited, and writes the edited inner HTML back to that element when the editor closes. Page scripts in the synced file get `null` for its `shadowRoot` and see events retargeted to the host, so they cannot reach the editor's live nodes through reflected properties such as a link's `href`, through references saved before the editor opened, or through another frame's DOM setters, including during a real paste. Removing the edited element or the shadow host reports `bd-edit:clobbered`, and nothing is saved.

## v0.18.9 — 2026-11-11

**Update self-hosted hubs** for faster history and cold starts on large
projects; **update your devices** to keep verified blobs across offline
cycles. Storage formats are unchanged.

- **Incremental history and fold checkpoint tails.** `restoreFoldCheckpoint`, `tryIncrementalFold` and the history index apply only appended journal tails, so a checkpoint is no longer discarded when a journal has grown and a live file with historical delete tombstones (such as `log.md`) no longer forces a rebuild. (#354)
- **Version-pinned range reads for journal tails.** `VersionedRangeGetter` / `GetVersionedRange` (GCS, forwarded through `remote.Prefixed`) read only the appended tail of a peer journal once its prefix digest is verified for that object generation. (#354)
- **Blob existence cache.** `RemoteSource` caches positive `blobs/` and `chunks/` existence checks after folder-visibility checks, and the daemon keeps its `httpBackend` across transient offline cycles, clearing verified blobs on a `404` or a journal-list reset. (#354)

## v0.18.8 — 2026-11-10

**Update self-hosted hubs** for the fold checkpoint, history and live tree
changes; **update your devices** for faster push retries. Storage formats are
unchanged.

- **Push retries skip blobs the hub already confirmed.** The `https://` backend remembers blobs and chunks confirmed by `Exists` or `Put` during a session (bounded FIFO), so a retry after a partial failure skips `/store/sign` and `/store/exists` for them and `Session.push` does not reopen their local files. (#351)
- **Derived fold checkpoint, pre-sorted history and hub hot-path caches.** The hub persists a fold checkpoint (`hub-cache/fold-v1.bin.gz`: live winners, delete tombstones, move history) so a cold instance restores a large project without re-parsing every journal; journal hashes are verified on restore. `histIndex` keeps a time-ordered permutation and `handleHistory` stops once the page is full, instead of sorting every op per request. `handleStoreSign` checks blob existence before quota reservation, so an org at its storage limit can still reference blobs already stored. Journal append and tail prefixes, unsealed blob generations, restricted tree responses and visible blob sets are cached. (#352)
- **Open tabs patch the file tree from change events.** Small SSE `change` frames (up to 16 paths) carry permission-filtered file metadata, so open tabs update their tree and since-visit caches without refetching `/tree` or `/history`; a reader with hidden paths falls back to a filtered refetch. The ambient history query runs only on Home, the 30- and 60-second `/comments` polls are gone, and a tab promoted to stream leader resyncs at once. (#353)

## v0.18.7 — 2026-11-10

**Update your devices** to reclaim superseded local blobs and skip redundant
Expand Down
8 changes: 7 additions & 1 deletion architecture/cli-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,18 @@ classDiagram
+tryMerge(path, mine, theirs, all) blob, ok
+mergeText(base, a, b) out, ok via textmerge
+commonAncestor(path, mine, theirs, all)
+latestPut(path, blob, lists) op, ok
-maxMergeBytes 4 MiB, UTF-8 only
}
note for merge "conflictCopiesWithState merges the losing op against the op that WON (latestPut: the greatest put holding the blob replay resolved to), fetching that blob first when it is not local. Lineage is never guessed from Base links. When the merge yields exactly the winner's bytes (merged blob == cur.Blob), the winner already holds both sides: another device or the hub merged first, so the cycle fast-forwards and writes no op. A real merge is journaled with Op.Base = the winning blob."
class textmerge {
<<internal/textmerge>>
+Merge(base, a, b) out, ok
+DiffHunks(old, new) []CharHunk
+RetainsChanges(base, candidate, head) bool
+IsText(b) bool
}
note for textmerge "Each side is diffed against the base with a Myers O(ND) line diff, so a side that touched several places yields several small hunks. Non-overlapping hunks apply independently (diff3). Overlaps resolve only for an identical edit, same-point insertions (ordered by content, never argument position), and one line both sides edited in different words (a token-level merge3). Everything else stays a conflict. DiffHunks gives minimal UTF-16 splices for a CRDT; RetainsChanges proves a later head still carries an earlier edit."

class daemon {
+Run(folder, scan, remote)
Expand Down Expand Up @@ -272,7 +278,7 @@ classDiagram
note for localFolderWatcher "The watcher accumulates bounded per-mount events, coalesces paths, prunes reserved/nested/ignored directories, and evaluates echo suppression outside pendingMu without loading the state cache when no pre-fence events are pending. Child ENOENT during recursive setup triggers candidate rebuild (releasing the prior watcher first on EMFILE/ENFILE/ENOSPC) and full-scan fallback when roots still exist; ENOSPC watcher exhaustion is retried with 1m/2m/5m/10m backoff and duplicate errors are logged once. Missing roots, closed channels, overflow and other backend errors remain fatal."
volumeWorker --> ScanHint : routes per-mount event batches
ScanHint ..> localFolderWatcher : batch source
note for Session "Concurrent edits to different parts of one text file MERGE now instead of forking. conflictCopies tries a three-way merge first (merge.go): the common ancestor is the greatest op for that path ordered before BOTH sides, which the journal already holds. It declines far more than it resolves — no ancestor, non-UTF-8 or NUL, over 4 MiB, an unreadable blob, or edits touching the same lines all fall through to exactly the conflict copy that existed before, because a machine guessing between two rewrites of one sentence is how people lose work quietly. Only NON-overlapping regions are ever taken, which makes merge(base,a,b) equal merge(base,b,a) — the property that lets two devices each observe the same concurrency and merge independently without pushing different blobs. Result.Merged is counted apart from Result.Conflicts: a merge is work the machine finished, a conflict is work it handed back. An EMPTY version never forks and never keeps a path: an empty loser is not preserved at all, and content that lost to an empty winner is put back at the real path (keptOverEmptyNote, counted as Merged) — a truncated save or a failed read written back is almost never an edit anyone meant, and a copy beside an empty file leaves the reader the empty one"
note for Session "Concurrent edits to different parts of one text file MERGE now instead of forking. conflictCopies tries a three-way merge first (merge.go): the common ancestor is the greatest op for that path ordered before BOTH sides, which the journal already holds. It declines far more than it resolves — no ancestor, non-UTF-8 or NUL, over 4 MiB, an unreadable blob, or two different rewrites of the same words all fall through to exactly the conflict copy that existed before, because a machine guessing between two rewrites of one sentence is how people lose work quietly. Only non-overlapping hunks (or, within one line, non-overlapping words) are ever taken, and every tie is broken by content, which makes merge(base,a,b) equal merge(base,b,a) — the property that lets two devices each observe the same concurrency and merge independently without pushing different blobs. Result.Merged is counted apart from Result.Conflicts: a merge is work the machine finished, a conflict is work it handed back. An EMPTY version never forks and never keeps a path: an empty loser is not preserved at all, and content that lost to an empty winner is put back at the real path (keptOverEmptyNote, counted as Merged) — a truncated save or a failed read written back is almost never an edit anyone meant, and a copy beside an empty file leaves the reader the empty one"

note for volumeWorker "remote.Watcher wakes a remote cycle when a peer pushes, reducing arrival latency from about 10s to 1s. A live stream stretches polling to remoteInterval x watchedPollFactor (5m by default); losing it restores remoteInterval on the next tick. Token changes and offline cycles drop the stream. Failed or ended dials back off for watchRetry (1m), including an older hub's 404. Periodic polling still bounds silent stream failure."
class pulledVouch {
Expand Down
4 changes: 2 additions & 2 deletions architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ flowchart LR

store["object store (hub-owned)<br/>internal/remote: file:// s3:// gs://<br/>blobs + per-device journals"]

tm["internal/textmerge<br/>line-level three-way merge,<br/>non-overlapping regions only"]
tm["internal/textmerge<br/>Myers multi-hunk diff3 merge + intra-line token merge<br/>Merge, DiffHunks, RetainsChanges, IsText"]

tpl["internal/templates<br/>go:embed'ed starting structures<br/>(docs, wiki, para, skills: skeleton + AGENTS.md)"]

Expand All @@ -58,7 +58,7 @@ flowchart LR
srv -->|"share mint: refuse · markdown render: badge"| sec
cli -->|"init --template: seed locally"| tpl
eng -->|"concurrent edits from two devices"| tm
srv -->|"an outside write under a co-editing room"| tm
srv -->|"co-editing room reconciliation, conditional<br/>upload/content, MCP write / edit on a stale sha"| tm
srv -->|"POST /api/projects template:<br/>seed as ops under the hub's device"| tpl
fe -->|/api/config, /api/projects, viewer APIs| srv
cloud -.->|imports OSS packages,<br/>replaces providers| srv
Expand Down
Loading
Loading