Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

docs(proposals): an edit format shared by leaf and the core - #23

Merged
adammharris merged 1 commit into
mainfrom
edit-format
Oct 26, 2026
Merged

adammharris merged 1 commit into
mainfrom
edit-format

Conversation

@adammharris

Copy link
Copy Markdown
Member

A proposal, nothing built. It answers decision 11 of Diaryx's The author's app runs in a browser: edits to the open page need an edit format shared by the core and leaf's Doc, which leaf designs first.

What it proposes, from Adam's decisions of 2026-10-22:

  • An edit is an Eg-walker event: retain/insert/delete ops in UTF-8 bytes of the page body, with a name and its parents. It goes as fig values (decision 10).
  • Concurrent edits merge by Eg-walker with Fugue, in a new public crate (eg-walker-merge, working name). historica's verified walk and its Verus proofs move into it, so leaf and historica share them.
  • twig gets a major version first: several splices applied with one reparse, and history optional.
  • Undo is local only. An undo is an inverse event, and the merge rebases it.
  • The editor and the worker each hold a replica of the open page. The graph is discarded at settle. A restore is one local, undoable edit.

Open questions are at the top of the document. Tasks for the new crate, twig, historica, leaf and diaryx are at the end.

adammharris added a commit to diaryx-org/twig that referenced this pull request Oct 24, 2026
…tep keeps their inverse

The splicer's one primitive is now apply(ops): Retain, Insert and Delete read from the start of the source, applied with one reparse and recorded as one undo step. A gesture still builds its replacement for a span, but replace_at_span records the fewest ops that turn the span's bytes into it (ast::ops::diff, Myers over characters, so no op ends inside a UTF-8 sequence, and one splice past 512 edits). Bold over a word is two inserts and the word retained, not the word deleted and written again, which is what a merge needs to keep a concurrent edit inside the word. edit_range, here and in the C ABI, records the span as asked. last_change keeps reporting the span asked.

Editor gains Op, apply (several places in one edit; a position past the end or inside a character is InvalidArgument), last_ops (what the last edit, undo or redo did, in one canonical spelling), and set_history / keeps_history. An undo step holds the edit's inverse ops and its caret blob instead of a copy of the whole source; coalescing composes two steps' ops. History off records no steps, for a host such as leaf that keeps its own over last_ops.

These are twig's tasks in leaf's draft proposal "An edit format shared by leaf and the core" (diaryx-org/leaf#23).

BREAKING CHANGE: ast::splicer::HistoryEntry holds `ops: Vec<ast::ops::Op>` where it held `source: Vec<u8>`, and ast::splicer::Error has an OutOfRange variant.

Behavioural-change: An undo or redo whose restored text the parser refuses
  now leaves its step on the stack, so it can be tried again. It used to drop
  the step.
@adammharris
adammharris marked this pull request as ready for review October 26, 2026 16:41
@adammharris
adammharris merged commit e205f90 into main Oct 26, 2026
6 checks passed
@adammharris
adammharris deleted the edit-format branch October 30, 2026 01:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant