Plan: Undo with block IDs (#671) #768

Closed
kayg wants to merge 11 commits from docs/undo-block-ids-plan into proto/block-identity-v7d
Owner

Repeated split/join Undo defects in #758 expose a shared identity invariant that native CRDT history does not preserve. Add a three-page design plan choosing server-validated structural inverse operations, durable boundary receipts, and one normaliser, while retaining native Undo for human text.

The plan compares all three options, specifies B5 concurrent-Undo behavior, O(edited region) work and the existing perf-VM bounds, shared invariant checks/property testing across the three harnesses and fuzz target, migration constraints, and five likely failure modes. Existing review reproducers remain required.

Documentation only, based on proto/block-identity-v7d at 57724c04. Validation: git diff --check; rendered as three A4 pages with 11-point body text. Product tests were not run for this writing task.

Refs #671 and #758; review comments 69930 and 69997.

Repeated split/join Undo defects in #758 expose a shared identity invariant that native CRDT history does not preserve. Add a three-page design plan choosing server-validated structural inverse operations, durable boundary receipts, and one normaliser, while retaining native Undo for human text. The plan compares all three options, specifies B5 concurrent-Undo behavior, O(edited region) work and the existing perf-VM bounds, shared invariant checks/property testing across the three harnesses and fuzz target, migration constraints, and five likely failure modes. Existing review reproducers remain required. Documentation only, based on proto/block-identity-v7d at 57724c04. Validation: git diff --check; rendered as three A4 pages with 11-point body text. Product tests were not run for this writing task. Refs #671 and #758; review comments 69930 and 69997.
docs: plan Undo with block IDs (#671)
Some checks failed
CI / server (pull_request) Successful in 1m14s
CI / rust (pull_request) Failing after 30m1s
CI / web (pull_request) Has been cancelled
2f1ac75963
Author
Owner

Independent design review — PR #768, round 1

Verdict: revise. Reviewed docs/undo-block-ids-plan at 2f1ac759636dedfb4679a1117f094b8725114cb8, based on 57724c04, on 10by32-01-std. Fresh detached worktree: /home/agent/wt/review-768.

The representation change is a credible direction. Removing structural separators from native Undo, retaining semantic boundary identity, and deriving separators once addresses the actual failure mechanism. The independent text/owner oracle, join probes, intermediate-delivery checks, and unchanged performance gates are also appropriate. However, three design blockers remain. These concern unspecified transitions and observable behavior; they are not claims that an implementation of this proposal has already failed.

Ranked blockers and required revisions

1. High: define rejection/rewrite reconciliation before promising offline inverse operations

Plan lines 86–106 say to validate dependencies/current membership atomically, predict locally, and rebase on accepted records without replaying human edits. They do not define the outcome when a predicted operation or its inverse is refused or rewritten.

Concrete scenario: A disconnects, splits a block, types into the new side, undoes that typing and then the split, and types again. B deletes the original block and syncs. On reconnect, delete-wins must keep A's text recoverable, while the new-side dependency and inverse must acquire a definite accepted, ineffective, or rejected result. Does A's provisional row disappear? Where can A recover its text? Does Undo now target the last typing step, a rejected split, or the previous accepted action? Retrying after an acknowledgement is lost or after a server restart must give the same answer. The plan currently supplies no answer to those questions.

There is also an unresolved contract boundary: “Rejected operations change nothing observable or durable” (line 35) cannot describe the whole lifecycle of an operation that already changed the offline screen and outbox. It can describe an immediate local refusal or an atomic server admission attempt. The later reconciliation needs its own contract.

This is a real protocol change from the current behavior: Device::sync retains a refused outbox and returns before replacing the device state; pull refuses to replace state while requests remain pending (client.rs:336–358). “Rebase” does not specify how that behavior changes. B5 defines server authority over IDs and immediate offline links; it does not supply this rejection protocol.

Required edits: specify a compact lifecycle for original operations, Undo and Redo: pending, accepted/canonicalized, ineffective, and rejected, including durable receipt identity and the authoritative result returned for each. Define how an inverse references an unacknowledged original, how canonicalized receipts and ID re-keys are followed, how dependent requests proceed after rejection, and how the local text document, recovery data, outbox, Undo stack and Redo stack are reconciled. Include duplicate delivery/lost acknowledgement/restart. Distinguish server rejection atomicity from observable rollback of a provisional prediction. State the user-visible result for the scenario above and for Undo of a refused original; neither may undo an unrelated earlier action.

2. High: define the boundary/ownership reducer sufficiently to determine remote-edit and nested-history results

Plan lines 68–85 introduce stable keys, ordered sides and “current membership,” but do not define how those sides acquire human items or how withdrawing nested split contributions changes membership. A deterministic normaliser can make an incorrect choice consistently. The proposed invariants are a strong oracle once expected history is defined; they do not themselves define that history.

Concrete scenario: start with linked blocks ab and cd. A joins them; B sees abcd and inserts X at the old seam. A then undoes its Join. Both abX | cd and ab | Xcd can have complete coverage, one separator, immutable claim owners, valid aliases and stable export. Which result is intended? An independent expected-history oracle cannot decide without a rule for insertion affinity/ownership at a suppressed boundary. Repeat with an empty side, with the seam's human anchors deleted and restored by native Undo, and with delivery/reload between those steps. Referring to causal positions alone does not choose a side or specify durable restoration of those positions.

Another required case is already represented by structured.rs::creation_undo_keeps_remote_human_bytes: A creates LOCAL, B inserts REMOTE inside it, A undoes creation, and B's bytes must remain visible. Withdrawing a structural creation/split cannot orphan those surviving human items. A first link created by B must also continue to target the prescribed surviving identity. The plan explicitly discusses another author's deletion but does not state the corresponding creation/remote-edit outcome.

The human/structural newline partition also needs a transition rule. Enter, multiline paste, deleting a selection across a separator, and a fence/table delimiter edit can combine human edits and structural effects. Specify whether existing newline roles remain attached to their original semantic records or change with grammar, and how Undo preserves their exact bytes in either case. The current format map can preserve owners even when Markdown grammar changes (format/edit.rs); the replacement must retain that ability.

Required edits: describe the semantic record fields and reducer rules for initial/imported boundaries, split creation/withdrawal, Join contribution/withdrawal, Redo, side ordering, owner/primary-ID placement, and human insertion/deletion affinity. Cover empty sides, tombstoned/restored human anchors, nested splits of joined groups, and surviving remote edits. Give literal text, owner and link-target expectations for the scenarios above. Expand the known reproducer walkthroughs below into explicit reducer outcomes. This need not be implementation code, but it must determine one result independently of the normaliser being tested.

3. Medium: include editor positions and one local history sequence in the contract

The invariant list, lines 11–39, never mentions caret, selection or the next Undo/Redo target. A state can satisfy every listed invariant while putting the caret in the wrong block.

For example, render a\nb with a derived structural separator and a human-only native text containing ab. The editor positions immediately before and after the separator map to the same human offset. A native text-relative position without a boundary-side identity cannot distinguish them. Undo, remote normalization or reconnect can move a caret/selection to the other side while text, ownership, ID resolution and disk round trips all remain correct. This is the requested counterexample to completeness of the stated invariants.

The existing browser editor binds yCollab and its native UndoManager directly to the shared Y.Text (packages/editor/src/editor.ts:120–138); the Rust prototype currently pairs each inverse with a native stack item (client_history.rs:9–17). Excluding separators from client text updates therefore needs an editor-position mapping and a history coordinator, not just a server reducer. A replacement selection spanning human text and a derived separator must be one user Undo step. Separate native and structural stacks would otherwise permit a valid intermediate document with the wrong next Undo target.

Required edits: add an editor contract for caret/selection anchors that includes boundary side/order, stable human positions and a defined fallback when the target is retired. Define a single chronological local action history pairing native text changes with semantic contributions, including grouping for Enter/paste/cross-boundary replacement. Require local completion and display before any network acknowledgement, online as well as offline; later authoritative correction must map the current selection rather than restore an obsolete numeric offset. Extend the checker inputs or add an editor-level companion checker with expected selection/history transitions, and require adapter tests alongside the crate harnesses. The full export/join-probe checker can remain test-only.

Walkthrough of the three known bugs

  1. Comment 69930: empty owner becomes unjoinable. Split neighbor at zero to create E before S; Join E/S suppresses their boundary; Undo must withdraw that Join while preserving E's independent empty-side order. Splitting S at byte 4 creates a second boundary between neig and hbor. The E/S boundary must remain between E and neig; the final Join E/S consumes that logical boundary and succeeds before and after reload. The proposed separation from native separator items removes the old collapsed-separator-anchor mechanism. The remaining proof obligation is the reducer's side/membership rule in blocker 2.

  2. Comment 69997: concurrent Undo duplicates a separator. Both offline Joins must reference the same existing boundary key with distinct contributions J_A and J_B. With both known, either local Undo alone leaves it joined. After U_A reaches the server, J_B still suppresses it, including across server restart. After U_B, the same boundary is exposed exactly once; duplicate packets and device reload cannot create another separator. This case is structurally addressed by the explicit contribution-set rule in lines 93–97, provided checkpoint/receipt replay preserves withdrawals. The visible no-op for the first Undo is intentional selective-Undo behavior.

  3. Comment 69997: nested history moves the empty prefix. Visible texts through the reproducer are ["", "text"] → ["text"] → ["text", ""] → ["", "text", ""] → ["", "text"]. Undoing the four actions must yield ["", "text", ""] → ["text", ""] → ["text"] → ["", "text"]. The original prefix boundary must retain its ordered empty side even while hidden inside later owner groups; target-id must return to the text group. Never restoring old display order is necessary. The plan names ordered sequence keys, but needs the membership/withdrawal rules to establish these intermediate outcomes by construction.

I would retain both reviewer branches unchanged as specified. The first repro is fixed on this base; the other two are documented remaining failures. This review inspected their source and prior findings; it did not rerun the implementation campaigns or add tests/code.

Concurrency and local UX assessment

  • Two devices Undo the same boundary: predictable under the explicit contribution rule above. If a device has not yet learned the other contribution, its provisional split can later become joined again. Distinguish that correction from the intentional no-op when both contributions are already known, and test each intermediate delivery state.
  • Offline Undo delivered later: local prediction is the right mechanism for immediate feedback. Reconnect behavior, especially when dependencies are rejected, remains blocked by finding 1. A confirmation-only design would fail the requested UX; make the online prediction rule explicit too.
  • Undo of a rejected/rewritten operation: currently unspecified; needs the lifecycle, canonical receipt mapping and history policy in finding 1.
  • Undo after a remote edit within the block: native selective text Undo is appropriate, and the remote author's bytes must survive. Their block/side assignment after structural Undo, and the resulting link target, remain unspecified at the old seam; finding 2 supplies the missing scenarios.

Cost assessment

Section 4 sets the right acceptance conditions: delta processing, indexed boundaries, no whole-note map rewrite/stringify on a keypress, grammar-bounded reparsing, and fixed-region scaling against note size and history depth. It does not yet establish an O(affected region + logarithmic lookup) implementation or a new timing result. The cited 0.504 ms added Enter p95 is the existing implementation's perf-VM baseline; the acceptance ceiling remains 1 ms, not 0.504 ms.

One specific measurement detail to add: include native CRDT items traversed and anchor-resolution work in the counters. An indexed semantic boundary lookup followed by StickyIndex::get_offset can still walk retained sequence history; the current code documents that behavior in text_positions.rs. Counting only materialized bytes or semantic records can miss it. Likewise, repeatedly splitting/undoing one short block must not force visits to every historical joined member. Test interleaved remote edits that invalidate cached positions, as well as the unchanged immediate Enter/Undo benchmark. Keep full invariant scans and durable-copy join probes outside the production keystroke path. No performance experiment is necessary to review this document, and I did not run one.

Simpler alternative worth separating in the decision

The table correctly rejects deriving identity from text alone and separating mixed edits by origin alone. It combines two independent decisions, however: semantic local history with derived separators, and server validation of every structural inverse. B5 requires server authority over public ID claims; it does not, by itself, require server arbitration of every boundary toggle.

Compare (c) with a local deterministic semantic contribution model using the same ordered receipts/normaliser, while the server remains authoritative for ID allocation, retirement and other genuinely conflicting operations. This would still require the representation change, so it is not a cheap origin-filter patch, but it may reduce rejection/rebase machinery. Explain which boundary conflict requires rejection rather than a deterministic accepted no-op or contribution merge. The review does not require selecting that alternative; it requires separating the rationale for semantic history from the rationale for expanding server validation.

Evidence and scope

Read the complete plan; ADR 0056 including B1–B5 and ADR 0022; issue #671 and the cited Undo/performance evidence; PR #758 comments 69930 and 69997; both reviewer branches (0f34e47f and 42aac955); and the relevant client history/edit/store, native text/position/projection, format, authority/admission/marker code and structural-history tests. Also inspected the browser history/editor integration for the cursor and grouping question.

Documentation review only. No repository edits, production fixes, deployments, or performance/test pass claims. Approval should wait for the three ranked revisions; the existing implementation/fuzz/perf gates remain delivery requirements afterward.

# Independent design review — PR #768, round 1 **Verdict: revise.** Reviewed `docs/undo-block-ids-plan` at `2f1ac759636dedfb4679a1117f094b8725114cb8`, based on `57724c04`, on `10by32-01-std`. Fresh detached worktree: `/home/agent/wt/review-768`. The representation change is a credible direction. Removing structural separators from native Undo, retaining semantic boundary identity, and deriving separators once addresses the actual failure mechanism. The independent text/owner oracle, join probes, intermediate-delivery checks, and unchanged performance gates are also appropriate. However, three design blockers remain. These concern unspecified transitions and observable behavior; they are not claims that an implementation of this proposal has already failed. ## Ranked blockers and required revisions ### 1. High: define rejection/rewrite reconciliation before promising offline inverse operations [Plan lines 86–106](https://git.kayg.org/kayg/calternal/src/commit/2f1ac759636dedfb4679a1117f094b8725114cb8/docs/plans/0671-undo.md#L86) say to validate dependencies/current membership atomically, predict locally, and rebase on accepted records without replaying human edits. They do not define the outcome when a predicted operation or its inverse is refused or rewritten. Concrete scenario: A disconnects, splits a block, types into the new side, undoes that typing and then the split, and types again. B deletes the original block and syncs. On reconnect, delete-wins must keep A's text recoverable, while the new-side dependency and inverse must acquire a definite accepted, ineffective, or rejected result. Does A's provisional row disappear? Where can A recover its text? Does Undo now target the last typing step, a rejected split, or the previous accepted action? Retrying after an acknowledgement is lost or after a server restart must give the same answer. The plan currently supplies no answer to those questions. There is also an unresolved contract boundary: “Rejected operations change nothing observable or durable” (line 35) cannot describe the whole lifecycle of an operation that already changed the offline screen and outbox. It can describe an immediate local refusal or an atomic server admission attempt. The later reconciliation needs its own contract. This is a real protocol change from the current behavior: `Device::sync` retains a refused outbox and returns before replacing the device state; `pull` refuses to replace state while requests remain pending (`client.rs:336–358`). “Rebase” does not specify how that behavior changes. B5 defines server authority over IDs and immediate offline links; it does not supply this rejection protocol. **Required edits:** specify a compact lifecycle for original operations, Undo and Redo: pending, accepted/canonicalized, ineffective, and rejected, including durable receipt identity and the authoritative result returned for each. Define how an inverse references an unacknowledged original, how canonicalized receipts and ID re-keys are followed, how dependent requests proceed after rejection, and how the local text document, recovery data, outbox, Undo stack and Redo stack are reconciled. Include duplicate delivery/lost acknowledgement/restart. Distinguish server rejection atomicity from observable rollback of a provisional prediction. State the user-visible result for the scenario above and for Undo of a refused original; neither may undo an unrelated earlier action. ### 2. High: define the boundary/ownership reducer sufficiently to determine remote-edit and nested-history results [Plan lines 68–85](https://git.kayg.org/kayg/calternal/src/commit/2f1ac759636dedfb4679a1117f094b8725114cb8/docs/plans/0671-undo.md#L68) introduce stable keys, ordered sides and “current membership,” but do not define how those sides acquire human items or how withdrawing nested split contributions changes membership. A deterministic normaliser can make an incorrect choice consistently. The proposed invariants are a strong oracle once expected history is defined; they do not themselves define that history. Concrete scenario: start with linked blocks `ab` and `cd`. A joins them; B sees `abcd` and inserts `X` at the old seam. A then undoes its Join. Both `abX | cd` and `ab | Xcd` can have complete coverage, one separator, immutable claim owners, valid aliases and stable export. Which result is intended? An independent expected-history oracle cannot decide without a rule for insertion affinity/ownership at a suppressed boundary. Repeat with an empty side, with the seam's human anchors deleted and restored by native Undo, and with delivery/reload between those steps. Referring to causal positions alone does not choose a side or specify durable restoration of those positions. Another required case is already represented by `structured.rs::creation_undo_keeps_remote_human_bytes`: A creates `LOCAL`, B inserts `REMOTE` inside it, A undoes creation, and B's bytes must remain visible. Withdrawing a structural creation/split cannot orphan those surviving human items. A first link created by B must also continue to target the prescribed surviving identity. The plan explicitly discusses another author's deletion but does not state the corresponding creation/remote-edit outcome. The human/structural newline partition also needs a transition rule. Enter, multiline paste, deleting a selection across a separator, and a fence/table delimiter edit can combine human edits and structural effects. Specify whether existing newline roles remain attached to their original semantic records or change with grammar, and how Undo preserves their exact bytes in either case. The current format map can preserve owners even when Markdown grammar changes (`format/edit.rs`); the replacement must retain that ability. **Required edits:** describe the semantic record fields and reducer rules for initial/imported boundaries, split creation/withdrawal, Join contribution/withdrawal, Redo, side ordering, owner/primary-ID placement, and human insertion/deletion affinity. Cover empty sides, tombstoned/restored human anchors, nested splits of joined groups, and surviving remote edits. Give literal text, owner and link-target expectations for the scenarios above. Expand the known reproducer walkthroughs below into explicit reducer outcomes. This need not be implementation code, but it must determine one result independently of the normaliser being tested. ### 3. Medium: include editor positions and one local history sequence in the contract [The invariant list, lines 11–39](https://git.kayg.org/kayg/calternal/src/commit/2f1ac759636dedfb4679a1117f094b8725114cb8/docs/plans/0671-undo.md#L11), never mentions caret, selection or the next Undo/Redo target. A state can satisfy every listed invariant while putting the caret in the wrong block. For example, render `a\nb` with a derived structural separator and a human-only native text containing `ab`. The editor positions immediately before and after the separator map to the same human offset. A native text-relative position without a boundary-side identity cannot distinguish them. Undo, remote normalization or reconnect can move a caret/selection to the other side while text, ownership, ID resolution and disk round trips all remain correct. This is the requested counterexample to completeness of the stated invariants. The existing browser editor binds `yCollab` and its native UndoManager directly to the shared Y.Text (`packages/editor/src/editor.ts:120–138`); the Rust prototype currently pairs each inverse with a native stack item (`client_history.rs:9–17`). Excluding separators from client text updates therefore needs an editor-position mapping and a history coordinator, not just a server reducer. A replacement selection spanning human text and a derived separator must be one user Undo step. Separate native and structural stacks would otherwise permit a valid intermediate document with the wrong next Undo target. **Required edits:** add an editor contract for caret/selection anchors that includes boundary side/order, stable human positions and a defined fallback when the target is retired. Define a single chronological local action history pairing native text changes with semantic contributions, including grouping for Enter/paste/cross-boundary replacement. Require local completion and display before any network acknowledgement, online as well as offline; later authoritative correction must map the current selection rather than restore an obsolete numeric offset. Extend the checker inputs or add an editor-level companion checker with expected selection/history transitions, and require adapter tests alongside the crate harnesses. The full export/join-probe checker can remain test-only. ## Walkthrough of the three known bugs 1. **Comment 69930: empty owner becomes unjoinable.** Split `neighbor` at zero to create E before S; Join E/S suppresses their boundary; Undo must withdraw that Join while preserving E's independent empty-side order. Splitting S at byte 4 creates a second boundary between `neig` and `hbor`. The E/S boundary must remain between E and `neig`; the final Join E/S consumes that logical boundary and succeeds before and after reload. The proposed separation from native separator items removes the old collapsed-separator-anchor mechanism. The remaining proof obligation is the reducer's side/membership rule in blocker 2. 2. **Comment 69997: concurrent Undo duplicates a separator.** Both offline Joins must reference the same existing boundary key with distinct contributions J_A and J_B. With both known, either local Undo alone leaves it joined. After U_A reaches the server, J_B still suppresses it, including across server restart. After U_B, the same boundary is exposed exactly once; duplicate packets and device reload cannot create another separator. This case is structurally addressed by the explicit contribution-set rule in lines 93–97, provided checkpoint/receipt replay preserves withdrawals. The visible no-op for the first Undo is intentional selective-Undo behavior. 3. **Comment 69997: nested history moves the empty prefix.** Visible texts through the reproducer are `["", "text"]` → `["text"]` → `["text", ""]` → `["", "text", ""]` → `["", "text"]`. Undoing the four actions must yield `["", "text", ""]` → `["text", ""]` → `["text"]` → `["", "text"]`. The original prefix boundary must retain its ordered empty side even while hidden inside later owner groups; `target-id` must return to the `text` group. Never restoring old display order is necessary. The plan names ordered sequence keys, but needs the membership/withdrawal rules to establish these intermediate outcomes by construction. I would retain both reviewer branches unchanged as specified. The first repro is fixed on this base; the other two are documented remaining failures. This review inspected their source and prior findings; it did not rerun the implementation campaigns or add tests/code. ## Concurrency and local UX assessment - **Two devices Undo the same boundary:** predictable under the explicit contribution rule above. If a device has not yet learned the other contribution, its provisional split can later become joined again. Distinguish that correction from the intentional no-op when both contributions are already known, and test each intermediate delivery state. - **Offline Undo delivered later:** local prediction is the right mechanism for immediate feedback. Reconnect behavior, especially when dependencies are rejected, remains blocked by finding 1. A confirmation-only design would fail the requested UX; make the online prediction rule explicit too. - **Undo of a rejected/rewritten operation:** currently unspecified; needs the lifecycle, canonical receipt mapping and history policy in finding 1. - **Undo after a remote edit within the block:** native selective text Undo is appropriate, and the remote author's bytes must survive. Their block/side assignment after structural Undo, and the resulting link target, remain unspecified at the old seam; finding 2 supplies the missing scenarios. ## Cost assessment Section 4 sets the right acceptance conditions: delta processing, indexed boundaries, no whole-note map rewrite/stringify on a keypress, grammar-bounded reparsing, and fixed-region scaling against note size **and history depth**. It does not yet establish an O(affected region + logarithmic lookup) implementation or a new timing result. The cited **0.504 ms added Enter p95** is the existing implementation's perf-VM baseline; the acceptance ceiling remains **1 ms**, not 0.504 ms. One specific measurement detail to add: include native CRDT items traversed and anchor-resolution work in the counters. An indexed semantic boundary lookup followed by `StickyIndex::get_offset` can still walk retained sequence history; the current code documents that behavior in `text_positions.rs`. Counting only materialized bytes or semantic records can miss it. Likewise, repeatedly splitting/undoing one short block must not force visits to every historical joined member. Test interleaved remote edits that invalidate cached positions, as well as the unchanged immediate Enter/Undo benchmark. Keep full invariant scans and durable-copy join probes outside the production keystroke path. No performance experiment is necessary to review this document, and I did not run one. ## Simpler alternative worth separating in the decision The table correctly rejects deriving identity from text alone and separating mixed edits by origin alone. It combines two independent decisions, however: **semantic local history with derived separators**, and **server validation of every structural inverse**. B5 requires server authority over public ID claims; it does not, by itself, require server arbitration of every boundary toggle. Compare (c) with a local deterministic semantic contribution model using the same ordered receipts/normaliser, while the server remains authoritative for ID allocation, retirement and other genuinely conflicting operations. This would still require the representation change, so it is not a cheap origin-filter patch, but it may reduce rejection/rebase machinery. Explain which boundary conflict requires rejection rather than a deterministic accepted no-op or contribution merge. The review does not require selecting that alternative; it requires separating the rationale for semantic history from the rationale for expanding server validation. ## Evidence and scope Read the complete plan; ADR 0056 including B1–B5 and ADR 0022; issue #671 and the cited Undo/performance evidence; PR #758 comments [69930](https://git.kayg.org/kayg/calternal/pulls/758#issuecomment-69930) and [69997](https://git.kayg.org/kayg/calternal/pulls/758#issuecomment-69997); both reviewer branches (`0f34e47f` and `42aac955`); and the relevant client history/edit/store, native text/position/projection, format, authority/admission/marker code and structural-history tests. Also inspected the browser history/editor integration for the cursor and grouping question. Documentation review only. No repository edits, production fixes, deployments, or performance/test pass claims. Approval should wait for the three ranked revisions; the existing implementation/fuzz/perf gates remain delivery requirements afterward.
Author
Owner

Round 2/3 revision pushed in ad60fee09b5ecf3734ef42a278c38a8c202ba702, addressing review 70006. Only docs/plans/0671-undo.md changed.

  1. Blocker 1 — rejection/replay: Added a shared original/Undo/Redo lifecycle (pending, accepted/canonicalized, ineffective, rejected), durable operation IDs, canonical effect/ID maps, dependency handling, and idempotent receipts across duplicate delivery, lost acknowledgements and restart. Specified replacement of stop-on-refusal sync/pending-pull refusal; reconciliation of text, recovery, outbox and both history directions; tombstoned native-ID scaffolding for later causal updates. The offline split/type/Undo/delete scenario now has explicit receipts, disappearing provisional row, recoverable bytes and next Undo target. Undo of a refused original consumes only its own history entry. Rejection atomicity is separate from correcting an already-visible prediction.

  2. Blocker 2 — ownership: Added record fields and reducer rules for imported/split cuts, ordered empty slots, generation-scoped Join contributions, split withdrawal/Redo, insertion affinity, durable tombstone/restoration anchors, remote-survivor container pins, claim placement/aliases and retirement contributions. Literal text/owner/link expectations cover the seam insertion (including empty and deleted/restored anchors), LOCAL/REMOTE creation Undo, and all three known reproducers. Existing newline roles stay fixed through grammar changes via the format map; Enter/paste/cross-cut edits undo as exact-byte mixed actions.

  3. Blocker 3 — editor/history: Added boundary-side selection anchors to distinguish equal human offsets, mapped Undo/Redo positions and retirement fallback, plus one chronological local action sequence pairing native text with semantic effects. Keyboard/Vim/menu/mobile/app Undo must share a coordinator and projection adapter. Every command displays immediately before acknowledgement, online and offline; correction maps the current selection. Added editor endpoint/next-target checks and adapter tests alongside crate harnesses.

  4. Should-fix — simpler alternative: Separated semantic history/derived separators from server arbitration. Recommend deterministic local contribution merge, with server guards for authorisation, dependencies, delete-wins and public IDs; ordinary boundary races merge or become ineffective rather than requiring rejection. B5 remains intact.

  5. Should-fix — cost/evidence: Added native CRDT-item traversal and anchor-resolution counters, retained-history/short-block scaling and remote cache invalidation. Kept O(edited region) normalisation, unchanged perf-VM gates and well-under-1-ms Enter goal at 10k lines. The 0.504-ms number remains the old baseline. Full invariant scans and join probes remain test-only; both reviewer branches remain unchanged.

  6. Product choices / failure analysis: Added “Decisions for kayg” with options, recommendations and visible examples for device history scope, Undo after remote edits/seam placement, and cursor placement/fallback. These are explicitly pending, not silently adopted. Updated the failure table / five likely failure modes.

Validation: git diff --check; checked table columns and local source links; rendered the body to 3 A4 pages (10.5-pt body, 9-pt tables, 16-mm margins), plus the decisions section. Docs-only writing round: no product-code edits, implementation-test/perf claims or deploys. Round-2 independent review is still required.

Round 2/3 revision pushed in `ad60fee09b5ecf3734ef42a278c38a8c202ba702`, addressing review [70006](https://git.kayg.org/kayg/calternal/pulls/768#issuecomment-70006). Only `docs/plans/0671-undo.md` changed. 1. **Blocker 1 — rejection/replay:** Added a shared original/Undo/Redo lifecycle (pending, accepted/canonicalized, ineffective, rejected), durable operation IDs, canonical effect/ID maps, dependency handling, and idempotent receipts across duplicate delivery, lost acknowledgements and restart. Specified replacement of stop-on-refusal sync/pending-pull refusal; reconciliation of text, recovery, outbox and both history directions; tombstoned native-ID scaffolding for later causal updates. The offline split/type/Undo/delete scenario now has explicit receipts, disappearing provisional row, recoverable bytes and next Undo target. Undo of a refused original consumes only its own history entry. Rejection atomicity is separate from correcting an already-visible prediction. 2. **Blocker 2 — ownership:** Added record fields and reducer rules for imported/split cuts, ordered empty slots, generation-scoped Join contributions, split withdrawal/Redo, insertion affinity, durable tombstone/restoration anchors, remote-survivor container pins, claim placement/aliases and retirement contributions. Literal text/owner/link expectations cover the seam insertion (including empty and deleted/restored anchors), `LOCAL`/`REMOTE` creation Undo, and all three known reproducers. Existing newline roles stay fixed through grammar changes via the format map; Enter/paste/cross-cut edits undo as exact-byte mixed actions. 3. **Blocker 3 — editor/history:** Added boundary-side selection anchors to distinguish equal human offsets, mapped Undo/Redo positions and retirement fallback, plus one chronological local action sequence pairing native text with semantic effects. Keyboard/Vim/menu/mobile/app Undo must share a coordinator and projection adapter. Every command displays immediately before acknowledgement, online and offline; correction maps the current selection. Added editor endpoint/next-target checks and adapter tests alongside crate harnesses. 4. **Should-fix — simpler alternative:** Separated semantic history/derived separators from server arbitration. Recommend deterministic local contribution merge, with server guards for authorisation, dependencies, delete-wins and public IDs; ordinary boundary races merge or become ineffective rather than requiring rejection. B5 remains intact. 5. **Should-fix — cost/evidence:** Added native CRDT-item traversal and anchor-resolution counters, retained-history/short-block scaling and remote cache invalidation. Kept O(edited region) normalisation, unchanged perf-VM gates and well-under-1-ms Enter goal at 10k lines. The 0.504-ms number remains the old baseline. Full invariant scans and join probes remain test-only; both reviewer branches remain unchanged. 6. **Product choices / failure analysis:** Added “Decisions for kayg” with options, recommendations and visible examples for device history scope, Undo after remote edits/seam placement, and cursor placement/fallback. These are explicitly pending, not silently adopted. Updated the failure table / five likely failure modes. Validation: `git diff --check`; checked table columns and local source links; rendered the body to **3 A4 pages** (10.5-pt body, 9-pt tables, 16-mm margins), plus the decisions section. Docs-only writing round: no product-code edits, implementation-test/perf claims or deploys. Round-2 independent review is still required.
Author
Owner

Independent design review — PR #768, round 2 of 3

Verdict: approve with required edits. Two bounded documentation edits are listed below. The three round-1 blockers are resolved at design level; neither required edit calls for a different representation or another open-ended design round.

Reviewed docs/undo-block-ids-plan at ad60fee09b on 10by32-01-std, in the fresh detached worktree /home/agent/wt/review-768b, created from origin/docs/undo-block-ids-plan. Line references below refer to this plan at the reviewed commit.

Required edits — exact list

  1. State the result of Undoing deletion after delayed text was put in recovery. Add one reducer example/paragraph beside lines 119–125 or the examples table, preserving review758::server_resolution_overrides_cached_local_claim_after_split_move_delete_reload on review/758-tests: A moves linked alpha; B, offline, inserts REMOTE at position 1; A deletes and syncs; B syncs; A pulls and Undoes the deletion. Before that Undo the block is retired and B's text is recovery-only. After it, the original ID resolves to aREMOTElpha in the moved destination, also after server restart/fresh-device load. Explain that the deletion-Undo effect can restore retained lineage text without changing the original terminal receipt; genuinely rejected text and text explicitly undone by its author must not be resurrected by this restoration. With another active deletion, it remains retired. Lines 55–57 restore retirement contributions, while lines 83 and 90–100 make blocked edits ineffective and exclude refused native items/restorations; the link between those rules and this existing passing control is currently implicit. This is a narrow restoration clarification, not a request to replay typing or to relax delete-wins.

  2. Apply the cost contract explicitly to the recovery journal. At lines 81/101–102, qualify “raw before/after text” as the changed spans plus durable shared-version/item references, or an equivalent delta representation, with full recovery reconstruction outside the key path. A one-character edit in a large note must not synchronously materialize/write two full-note strings. Require the fixed-region cost check to include recovery capture/persistence preparation as well as normalisation, selection mapping and native anchor work. This removes an avoidable full-snapshot reading of the new recovery requirement; it does not change the perf budget or demand a new benchmark in this writing round.

Round-1 blockers

1. Rejection/replay — resolved. Lines 76–105 now define pending, accepted/canonicalized, ineffective and rejected outcomes for originals and inverses. Stable operation IDs and payload hashes, persisted receipts and canonical mappings make duplicate delivery/lost acknowledgement/server restart deterministic. Dependents of absent sides become ineffective while independent requests continue. Tombstoned causal scaffolding and receipt-aware projection address the missing-clock problem without replaying human commands. The plan expressly replaces stop-on-refusal sync and the pending-pull prohibition.

The original offline split → type → Undo typing → Undo split → type scenario has a definite result after B deletes the lineage: the provisional row disappears, its ID remains retired, all provisional text remains recoverable, and the next Undo consumes only the last typing entry and explains the no-op. A refused original also consumes its own entry. Rejected inverses roll back prediction and restore that entry's eligibility without popping an unrelated action. Server rejection atomicity is correctly separated from correcting a screen that already displayed a prediction. Required edit 1 covers the subsequent deletion-Undo compatibility case, rather than reopening this lifecycle.

2. Ownership after remote edits — resolved. Lines 24–62 supply durable cut keys, ordered owner slots, retained gap/tombstone identities, restoration mappings, contribution generations and side affinity. Exposed cuts partition ordered intervals; withdrawing a Join changes only its contribution. Split withdrawal preserves surviving runs and pinned handles in the merged group. Human ownership is no longer reconstructed from a repaired newline or the nearest current offset.

Under the proposed K2 default, joining linked ab/cd, inserting X at the hidden seam and Undoing Join gives ab | Xcd, with original L/R link ownership restored separately. Empty left and deleted/restored b/c anchors have literal outcomes too. Undoing creation of LOCAL after B inserts/links REMOTE leaves REMOTE in C, and B's link stays on C. Fixed newline roles and the format map preserve exact human bytes through grammar changes; Enter/paste/cross-cut replacement pair bytes and semantic effects in one action. These are independently checkable rules, rather than an assertion that a deterministic normaliser will choose correctly.

3. Cursor/selection and unified history — resolved. Lines 107–136 define one chronological local sequence pairing native text stack items, semantic effects and before/after anchors. Enter, paste, cross-cut replacement, IME and make-note-from-block have explicit grouping; all command surfaces must share the coordinator. Boundary side/order distinguishes the two projected positions at human offset 1 in a\nb. Undo/Redo map stored action anchors; remote correction maps the current selection; retirement has a deterministic fallback. Editor endpoint/next-target assertions and adapter tests accompany the crate oracles. Correct text with the wrong next Undo target or caret is now explicitly a failure.

Reproducer walkthroughs

Reproducer / coverage Reducer outcome and why the reported failure cannot occur
69930: empty owner becomes unjoinable, review758_minimal Split-at-zero creates E before S; Join suppresses their existing cut; Undo exposes that same cut. Splitting S at 4 inserts a different cut without moving E: `""
69997: concurrent Undo duplicates a separator, both review758b files A/B Join contributions name one base cut. After U_A, J_B still suppresses it; after U_B, that one cut is exposed once. Exact-generation withdrawals and persisted receipts survive duplicate packets/restart. A reloaded Join suppresses the same cut again, yielding alphabeta; no native Undo can insert an extra separator. Unknown remote contributions may correct a provisional split later, as the plan explicitly permits.
69997: nested history moves the empty prefix, both review758b files E/S Join; tail split T; zero split P; middle/tail Join produce text → `text
Broader reviewer coverage Deep/random split-Join history uses the same stable ordered cuts and literal-history oracle; disjoint concurrent operations affect separate cuts; Redo uses fresh generations. B5 collision/re-key controls follow proposal identity and immutable claim owners, not ID-string replacement. Partial delivery/lost replies/restarts use durable receipts and causal item IDs. Bootstrap/exact-byte/Unicode cases retain format-owned separator bytes and causal positions. The move/delete/delayed-edit control needs the explicit outcome in required edit 1.

The plan requires the reviewer branches unchanged, the checker to catch the two remaining failures on the base, and checks after intermediate publication/delivery/reload—not merely final convergence. That is the right implementation gate. This walkthrough establishes removal of the three reported failure mechanisms by construction; it is not a claim that the unimplemented reducer or randomized campaigns have passed.

Immediate/offline behavior and performance

Lines 7–8 explicitly require local display before acknowledgement for every edit/Undo/Redo, online and offline, with atomic text/owners/projection/selection publication. Ordinary boundary races merge locally instead of waiting for server arbitration. B5 still guards public IDs. Reconnect correction and recovery do not block the initial command. This satisfies the requested interaction contract.

The normalisation budget is preserved: O(edited region) plus O(log note size) lookup, delta ropes, indexed cuts/owners and contribution counts/shared endpoints; no whole-note rewrite or historical-member walk. Native item traversal and anchor resolution are now counted, including remote cache invalidation and repeated split/Undo of a short block as retained history grows. Head-walking StickyIndex::get_offset is expressly forbidden as a hidden fallback. Grammar-changing fences may enlarge the actual region; ordinary Enter may not. Required edit 2 extends this same discipline to the new synchronous recovery obligation.

The unchanged seven-key and immediate Enter/Undo/Redo perf-VM gates remain, with well-under-1-ms added Enter p95 at 10k lines/500 links and a hard 1-ms ceiling. 0.504 ms is prior-implementation evidence only. The design provides a plausible bounded path and enforceable acceptance criteria, not proof of a new timing result. Implementation approval still requires the listed functional, fuzz, editor and perf evidence.

Decisions for kayg

K1–K3 are real product choices, with options, recommendations and observable consequences:

  • K1: whether phone Undo can undo the user's laptop edit, versus device-local history. The session-ending-at-restart scope is disclosed; retaining that existing scope need not become a new design blocker. If shared history is chosen, its different lifetime must be reconciled with that scope before implementation.
  • K2: preserve the other person's words while Undoing one's own change, versus refuse that Undo; separately, seam words start the second block or end the first (ab | Xcd versus abX | cd). These can be answered independently despite sharing a heading. The recommended preservation rule fits ADR 0022.
  • K3: restore the action's mapped caret versus keep the current mapped caret, and next-first versus previous-first fallback when its target disappears. Each changes what the person sees; stable anchors and the projection adapter are engineering obligations, not choices delegated to kayg.

The section correctly labels these as pending and uses the recommendations only to make the examples definite. No additional product decision is needed to resolve the three reviewed failures. The two required edits concern compatibility and bounded implementation work, and should not be turned into questions for kayg. Chosen alternatives must be reflected in the examples and editor oracle before implementation approval.

Evidence and scope

Read the round-1 report at /home/agent/codex-jobs/review-768/review.md / 70006, the author's 70016, the complete revised plan, ADR 0056 and ADR 0022, issue #671 and relevant review/perf comments, both reviewer branches at 0f34e47f77579e03deebabb14a57f9054ed1fb99 and 42aac955e4944a612a8c6ea6f6ca68ca212eeb59, their minimal/random/control test source, and the relevant block-ids client/history/store, authority/admission/recovery, projection/position/format and editor-binding code.

Documentation review only. Worktree HEAD and cleanliness verified; git diff --check passed. No repository source edits, new tests, test/perf execution, commits, merges or deployments. The required edits are documentation changes for the author; this reviewer has not changed the plan.

# Independent design review — PR #768, round 2 of 3 **Verdict: approve with required edits.** Two bounded documentation edits are listed below. The three round-1 blockers are resolved at design level; neither required edit calls for a different representation or another open-ended design round. Reviewed `docs/undo-block-ids-plan` at **ad60fee09b5ecf3734ef42a278c38a8c202ba702** on **10by32-01-std**, in the fresh detached worktree `/home/agent/wt/review-768b`, created from `origin/docs/undo-block-ids-plan`. Line references below refer to [this plan at the reviewed commit](https://git.kayg.org/kayg/calternal/src/commit/ad60fee09b5ecf3734ef42a278c38a8c202ba702/docs/plans/0671-undo.md). ## Required edits — exact list 1. **State the result of Undoing deletion after delayed text was put in recovery.** Add one reducer example/paragraph beside lines 119–125 or the examples table, preserving `review758::server_resolution_overrides_cached_local_claim_after_split_move_delete_reload` on `review/758-tests`: A moves linked `alpha`; B, offline, inserts `REMOTE` at position 1; A deletes and syncs; B syncs; A pulls and Undoes the deletion. Before that Undo the block is retired and B's text is recovery-only. After it, the original ID resolves to **`aREMOTElpha` in the moved destination**, also after server restart/fresh-device load. Explain that the deletion-Undo effect can restore retained lineage text without changing the original terminal receipt; genuinely rejected text and text explicitly undone by its author must not be resurrected by this restoration. With another active deletion, it remains retired. Lines 55–57 restore retirement contributions, while lines 83 and 90–100 make blocked edits ineffective and exclude refused native items/restorations; the link between those rules and this existing passing control is currently implicit. This is a narrow restoration clarification, not a request to replay typing or to relax delete-wins. 2. **Apply the cost contract explicitly to the recovery journal.** At lines 81/101–102, qualify “raw before/after text” as the changed spans plus durable shared-version/item references, or an equivalent delta representation, with full recovery reconstruction outside the key path. A one-character edit in a large note must not synchronously materialize/write two full-note strings. Require the fixed-region cost check to include recovery capture/persistence preparation as well as normalisation, selection mapping and native anchor work. This removes an avoidable full-snapshot reading of the new recovery requirement; it does not change the perf budget or demand a new benchmark in this writing round. ## Round-1 blockers **1. Rejection/replay — resolved.** Lines 76–105 now define pending, accepted/canonicalized, ineffective and rejected outcomes for originals and inverses. Stable operation IDs and payload hashes, persisted receipts and canonical mappings make duplicate delivery/lost acknowledgement/server restart deterministic. Dependents of absent sides become ineffective while independent requests continue. Tombstoned causal scaffolding and receipt-aware projection address the missing-clock problem without replaying human commands. The plan expressly replaces stop-on-refusal sync and the pending-pull prohibition. The original offline split → type → Undo typing → Undo split → type scenario has a definite result after B deletes the lineage: the provisional row disappears, its ID remains retired, all provisional text remains recoverable, and the next Undo consumes only the last typing entry and explains the no-op. A refused original also consumes its own entry. Rejected inverses roll back prediction and restore that entry's eligibility without popping an unrelated action. Server rejection atomicity is correctly separated from correcting a screen that already displayed a prediction. Required edit 1 covers the subsequent deletion-Undo compatibility case, rather than reopening this lifecycle. **2. Ownership after remote edits — resolved.** Lines 24–62 supply durable cut keys, ordered owner slots, retained gap/tombstone identities, restoration mappings, contribution generations and side affinity. Exposed cuts partition ordered intervals; withdrawing a Join changes only its contribution. Split withdrawal preserves surviving runs and pinned handles in the merged group. Human ownership is no longer reconstructed from a repaired newline or the nearest current offset. Under the proposed K2 default, joining linked `ab`/`cd`, inserting `X` at the hidden seam and Undoing Join gives **`ab | Xcd`**, with original L/R link ownership restored separately. Empty left and deleted/restored b/c anchors have literal outcomes too. Undoing creation of `LOCAL` after B inserts/links `REMOTE` leaves **`REMOTE` in C**, and B's link stays on C. Fixed newline roles and the format map preserve exact human bytes through grammar changes; Enter/paste/cross-cut replacement pair bytes and semantic effects in one action. These are independently checkable rules, rather than an assertion that a deterministic normaliser will choose correctly. **3. Cursor/selection and unified history — resolved.** Lines 107–136 define one chronological local sequence pairing native text stack items, semantic effects and before/after anchors. Enter, paste, cross-cut replacement, IME and make-note-from-block have explicit grouping; all command surfaces must share the coordinator. Boundary side/order distinguishes the two projected positions at human offset 1 in `a\nb`. Undo/Redo map stored action anchors; remote correction maps the current selection; retirement has a deterministic fallback. Editor endpoint/next-target assertions and adapter tests accompany the crate oracles. Correct text with the wrong next Undo target or caret is now explicitly a failure. ## Reproducer walkthroughs | Reproducer / coverage | Reducer outcome and why the reported failure cannot occur | | --- | --- | | **69930: empty owner becomes unjoinable**, `review758_minimal` | Split-at-zero creates E before S; Join suppresses their existing cut; Undo exposes that same cut. Splitting S at 4 inserts a different cut without moving E: `"" | neig | hbor`. Joining E/S consumes the original cut and yields `neig | hbor`. E's empty slot survives independently of native separator anchors, including checkpoint reload. There is no collapsed separator position to make adjacent groups unjoinable. | | **69997: concurrent Undo duplicates a separator**, both `review758b` files | A/B Join contributions name one base cut. After U_A, J_B still suppresses it; after U_B, that one cut is exposed once. Exact-generation withdrawals and persisted receipts survive duplicate packets/restart. A reloaded Join suppresses the same cut again, yielding `alphabeta`; no native Undo can insert an extra separator. Unknown remote contributions may correct a provisional split later, as the plan explicitly permits. | | **69997: nested history moves the empty prefix**, both `review758b` files | E/S Join; tail split T; zero split P; middle/tail Join produce `text` → `text | ""` → `"" | text | ""` → `"" | text`. Four Undos yield `["","text",""]` → `["text",""]` → `["text"]` → `["","text"]`. Each Undo changes its own cut/contribution; the original E/S order is retained and `target-id` follows S. Restoring saved display order or following local-only `redone` pointers is unnecessary. | | **Broader reviewer coverage** | Deep/random split-Join history uses the same stable ordered cuts and literal-history oracle; disjoint concurrent operations affect separate cuts; Redo uses fresh generations. B5 collision/re-key controls follow proposal identity and immutable claim owners, not ID-string replacement. Partial delivery/lost replies/restarts use durable receipts and causal item IDs. Bootstrap/exact-byte/Unicode cases retain format-owned separator bytes and causal positions. The move/delete/delayed-edit control needs the explicit outcome in required edit 1. | The plan requires the reviewer branches unchanged, the checker to catch the two remaining failures on the base, and checks after intermediate publication/delivery/reload—not merely final convergence. That is the right implementation gate. This walkthrough establishes removal of the three reported failure mechanisms by construction; it is not a claim that the unimplemented reducer or randomized campaigns have passed. ## Immediate/offline behavior and performance Lines 7–8 explicitly require local display before acknowledgement for every edit/Undo/Redo, online and offline, with atomic text/owners/projection/selection publication. Ordinary boundary races merge locally instead of waiting for server arbitration. B5 still guards public IDs. Reconnect correction and recovery do not block the initial command. This satisfies the requested interaction contract. The normalisation budget is preserved: **O(edited region) plus O(log note size) lookup**, delta ropes, indexed cuts/owners and contribution counts/shared endpoints; no whole-note rewrite or historical-member walk. Native item traversal and anchor resolution are now counted, including remote cache invalidation and repeated split/Undo of a short block as retained history grows. Head-walking `StickyIndex::get_offset` is expressly forbidden as a hidden fallback. Grammar-changing fences may enlarge the actual region; ordinary Enter may not. Required edit 2 extends this same discipline to the new synchronous recovery obligation. The unchanged seven-key and immediate Enter/Undo/Redo perf-VM gates remain, with well-under-1-ms added Enter p95 at 10k lines/500 links and a hard 1-ms ceiling. **0.504 ms is prior-implementation evidence only.** The design provides a plausible bounded path and enforceable acceptance criteria, not proof of a new timing result. Implementation approval still requires the listed functional, fuzz, editor and perf evidence. ## Decisions for kayg K1–K3 are real product choices, with options, recommendations and observable consequences: - **K1:** whether phone Undo can undo the user's laptop edit, versus device-local history. The session-ending-at-restart scope is disclosed; retaining that existing scope need not become a new design blocker. If shared history is chosen, its different lifetime must be reconciled with that scope before implementation. - **K2:** preserve the other person's words while Undoing one's own change, versus refuse that Undo; separately, seam words start the second block or end the first (`ab | Xcd` versus `abX | cd`). These can be answered independently despite sharing a heading. The recommended preservation rule fits ADR 0022. - **K3:** restore the action's mapped caret versus keep the current mapped caret, and next-first versus previous-first fallback when its target disappears. Each changes what the person sees; stable anchors and the projection adapter are engineering obligations, not choices delegated to kayg. The section correctly labels these as pending and uses the recommendations only to make the examples definite. No additional product decision is needed to resolve the three reviewed failures. The two required edits concern compatibility and bounded implementation work, and should not be turned into questions for kayg. Chosen alternatives must be reflected in the examples and editor oracle before implementation approval. ## Evidence and scope Read the round-1 report at `/home/agent/codex-jobs/review-768/review.md` / [70006](https://git.kayg.org/kayg/calternal/pulls/768#issuecomment-70006), the author's [70016](https://git.kayg.org/kayg/calternal/pulls/768#issuecomment-70016), the complete revised plan, ADR 0056 and ADR 0022, issue #671 and relevant review/perf comments, both reviewer branches at `0f34e47f77579e03deebabb14a57f9054ed1fb99` and `42aac955e4944a612a8c6ea6f6ca68ca212eeb59`, their minimal/random/control test source, and the relevant block-ids client/history/store, authority/admission/recovery, projection/position/format and editor-binding code. Documentation review only. Worktree HEAD and cleanliness verified; `git diff --check` passed. No repository source edits, new tests, test/perf execution, commits, merges or deployments. The required edits are documentation changes for the author; this reviewer has not changed the plan.
Author
Owner

Applied the two required edits from round-2 review 70018 in 003f869c399fe39accb518d05a6b56a9142c796d. Only docs/plans/0671-undo.md changed, including matching failure-table rows 1 and 5. “Decisions for kayg” is unchanged byte-for-byte.

  1. Deletion Undo restores delayed remote text:

Deletion Undo and delayed text. A moves linked alpha to destination;
B, offline, inserts REMOTE at position 1 before receiving A's deletion. A deletes
and syncs; B syncs; A pulls. The block is retired and B's text is recovery-only.
When A Undoes the deletion, the user sees aREMOTElpha in destination, and the
original ID resolves there, also after server restart/fresh-device load. Nothing
is lost: the deletion-Undo effect restores retained lineage text blocked only by
that retirement, using durable item/restoration references without replaying
typing or changing the original terminal receipt. Genuinely rejected text and
text explicitly undone by its author stay excluded from live text and retained
in recovery. Another active deletion keeps the lineage retired and its text in
recovery. Preserve
review758::server_resolution_overrides_cached_local_claim_after_split_move_delete_reload
on review/758-tests unchanged.

  1. Recovery journal representation and bounded cost:

Persist raw before/after changed spans plus durable shared-version/item references
(or equivalent deltas), item IDs, dependency chain and receipt reasons in
recoverable note history, including text already locally undone. Retain referenced
versions/items so no bytes are lost; reconstruct full recovery text outside the
key path. A one-character edit must not synchronously materialise or write two
full-note strings. Remove only terminal requests from outbox; retain receipts for
history and deduplication.

Normalisation, Undo, Redo and recovery capture/persistence preparation and
application stay O(edited region) plus O(log note size) lookup, with journal
bytes proportional to changed spans/references: delta ropes, indexed cuts/owners,
contribution counts/shared endpoints; no O(note) step, whole-note stringify/map
rewrites or history walks. Full recovery reconstruction is outside the key path
and costs O(requested recovery output), not a mandatory full-note scan. Parse to
stable grammar boundaries; fences may extend to EOF, ordinary Enter may not. Count
native CRDT items traversed, anchor-resolution
work, visited records/bytes and materialisation. Fixed-region cost checks include
normalisation, selection mapping, native anchor work and recovery capture/persistence
preparation and application for edits, Undo and Redo. Increase note size AND
retained history; repeatedly split/undo one short block and interleave remote
cache-invalidating edits.

Validation: git diff --check passed; verified the single-file scope and unchanged decisions section. Documentation only; no product code changes or test/perf runs.

Applied the two required edits from [round-2 review 70018](https://git.kayg.org/kayg/calternal/pulls/768#issuecomment-70018) in `003f869c399fe39accb518d05a6b56a9142c796d`. Only `docs/plans/0671-undo.md` changed, including matching failure-table rows 1 and 5. “Decisions for kayg” is unchanged byte-for-byte. 1. Deletion Undo restores delayed remote text: > **Deletion Undo and delayed text.** A moves linked `alpha` to `destination`; > B, offline, inserts `REMOTE` at position 1 before receiving A's deletion. A deletes > and syncs; B syncs; A pulls. The block is retired and B's text is recovery-only. > When A Undoes the deletion, the user sees `aREMOTElpha` in `destination`, and the > original ID resolves there, also after server restart/fresh-device load. Nothing > is lost: the deletion-Undo effect restores retained lineage text blocked only by > that retirement, using durable item/restoration references without replaying > typing or changing the original terminal receipt. Genuinely rejected text and > text explicitly undone by its author stay excluded from live text and retained > in recovery. Another active deletion keeps the lineage retired and its text in > recovery. Preserve > `review758::server_resolution_overrides_cached_local_claim_after_split_move_delete_reload` > on `review/758-tests` unchanged. 2. Recovery journal representation and bounded cost: > Persist raw before/after changed spans plus durable shared-version/item references > (or equivalent deltas), item IDs, dependency chain and receipt reasons in > recoverable note history, including text already locally undone. Retain referenced > versions/items so no bytes are lost; reconstruct full recovery text outside the > key path. A one-character edit must not synchronously materialise or write two > full-note strings. Remove only terminal requests from outbox; retain receipts for > history and deduplication. > Normalisation, Undo, Redo and recovery capture/persistence preparation and > application stay **O(edited region) plus O(log note size) lookup**, with journal > bytes proportional to changed spans/references: delta ropes, indexed cuts/owners, > contribution counts/shared endpoints; no O(note) step, whole-note stringify/map > rewrites or history walks. Full recovery reconstruction is outside the key path > and costs O(requested recovery output), not a mandatory full-note scan. Parse to > stable grammar boundaries; fences may extend to EOF, ordinary Enter may not. Count > native CRDT items traversed, anchor-resolution > work, visited records/bytes and materialisation. Fixed-region cost checks include > normalisation, selection mapping, native anchor work and recovery capture/persistence > preparation and application for edits, Undo and Redo. Increase note size AND > retained history; repeatedly split/undo one short block and interleave remote > cache-invalidating edits. Validation: `git diff --check` passed; verified the single-file scope and unchanged decisions section. Documentation only; no product code changes or test/perf runs.
Author
Owner

housekeeping #1009: rebased+green for the targeted gates below, left open for review.

rebased undo/block identity proposal on #758.

head: be9023beb946bb211e8db72c6055465f13a0c1a1, based on dev cd7f84432febfc63b788fbb9b9f9950452982d74; pushed with the original exact force-with-lease.

Mac VM validation through Nix and the shared Mac lock/slot passed: frontend frozen install, check, lint, build, bundle gate and unit tests; cargo fmt -p calternal-block-ids -- --check; cargo check -j4 --locked -p calternal-block-ids --all-targets; cargo clippy -j4 --locked -p calternal-block-ids --all-targets -- -D warnings; cargo test -j4 --locked -p calternal-block-ids --lib (35 tests). frontend inputs are unchanged since the initial frontend pass. commands and logs.

this is prototype/package validation. the historical five-hour verify5 randomized qualification, fuzzing and performance qualification were not rerun; no merge or production-readiness claim. carriage-return/CRLF fuzz seeds intentionally retain their original line-ending bytes.

original-head patch inventory, pr-768.md.

housekeeping #1009: rebased+green for the targeted gates below, left open for review. rebased undo/block identity proposal on #758. head: `be9023beb946bb211e8db72c6055465f13a0c1a1`, based on dev `cd7f84432febfc63b788fbb9b9f9950452982d74`; pushed with the original exact force-with-lease. Mac VM validation through Nix and the shared Mac lock/slot passed: frontend frozen install, check, lint, build, bundle gate and unit tests; `cargo fmt -p calternal-block-ids -- --check`; `cargo check -j4 --locked -p calternal-block-ids --all-targets`; `cargo clippy -j4 --locked -p calternal-block-ids --all-targets -- -D warnings`; `cargo test -j4 --locked -p calternal-block-ids --lib` (35 tests). frontend inputs are unchanged since the initial frontend pass. [commands and logs](https://git.kayg.org/attachments/5d5ac1c9-ce11-452e-adac-1b906de54ef4). this is prototype/package validation. the historical five-hour verify5 randomized qualification, fuzzing and performance qualification were not rerun; no merge or production-readiness claim. carriage-return/CRLF fuzz seeds intentionally retain their original line-ending bytes. [original-head patch inventory](https://git.kayg.org/attachments/e05a38dc-c028-4d77-8655-efa9d5c8ea50), `pr-768.md`.
Author
Owner

triage 2026-11-11: closing as covered plan: Undo/block-ID plan is carried byte-for-byte in implementation #816, on #758.

triage 2026-11-11: closing as covered plan: Undo/block-ID plan is carried byte-for-byte in implementation #816, on #758.
kayg closed this pull request 2026-11-11 08:33:10 +00:00
Some checks failed
CI / server (pull_request) Successful in 1m14s
CI / rust (pull_request) Failing after 30m1s
CI / web (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!768
No description provided.