Fix block identity undo anchors (#768) #816

Open
kayg wants to merge 12 commits from fix/undo-768 into proto/block-identity-v7d
Owner

Cause → fix → test

Cause Fix Regression coverage
Creation undo used a left-associated start anchor, allowing restored text to absorb a neighboring block. Use Span::inserted so restored bytes retain their own identity span. k2_creation_undo_preserves_remote_text_and_the_remote_claim (unit and integration) and creation_undo_keeps_remote_human_bytes.
A Yrs root referenced by an update could remain Undefined, so replay could skip materializing the remote text/claim. Materialize referenced root names as text before replay. The three creation-undo remote-text regressions above.
The TS adapter treated a retired owner as offset zero, losing its historical position when resolving the selection. Retain retired offsets and compare gapless endpoints structurally. vitest run test/prototype/undo.test.ts (10 tests).

Undo matrix

Invariant Result
K1: undo is per device Pass; undo applies to the local device's history.
K2: undo keeps other people's text Pass; all three creation-undo remote-text cases pass.
K3: cursor returns to its prior position Pass; the adapter regression tests pass.

Verification

  • cargo test -p calternal-block-ids --test undo768 --test review758b --test review758b_minimal --test structured: pass (5 + 5 + 2 + 6 tests).
  • vitest run test/prototype/undo.test.ts: pass (10 tests).
  • cargo test -p calternal-block-ids -j4: attempted on dev-01; all earlier suites passed, but the configured 3-hour systemd limit stopped the run during verify5::independent_seeded_runs. No assertion failure was reported; the full crate gate did not complete.
## Cause → fix → test | Cause | Fix | Regression coverage | | --- | --- | --- | | Creation undo used a left-associated start anchor, allowing restored text to absorb a neighboring block. | Use `Span::inserted` so restored bytes retain their own identity span. | `k2_creation_undo_preserves_remote_text_and_the_remote_claim` (unit and integration) and `creation_undo_keeps_remote_human_bytes`. | | A Yrs root referenced by an update could remain `Undefined`, so replay could skip materializing the remote text/claim. | Materialize referenced root names as text before replay. | The three creation-undo remote-text regressions above. | | The TS adapter treated a retired owner as offset zero, losing its historical position when resolving the selection. | Retain retired offsets and compare gapless endpoints structurally. | `vitest run test/prototype/undo.test.ts` (10 tests). | ## Undo matrix | Invariant | Result | | --- | --- | | K1: undo is per device | Pass; undo applies to the local device's history. | | K2: undo keeps other people's text | Pass; all three creation-undo remote-text cases pass. | | K3: cursor returns to its prior position | Pass; the adapter regression tests pass. | ## Verification - `cargo test -p calternal-block-ids --test undo768 --test review758b --test review758b_minimal --test structured`: pass (5 + 5 + 2 + 6 tests). - `vitest run test/prototype/undo.test.ts`: pass (10 tests). - `cargo test -p calternal-block-ids -j4`: attempted on dev-01; all earlier suites passed, but the configured 3-hour systemd limit stopped the run during `verify5::independent_seeded_runs`. No assertion failure was reported; the full crate gate did not complete.
fix block identity undo anchors
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
4559b1dd2c
Author
Owner

Independent review, round 1

  • P0: none.
  • P1: none.
  • P2: packages/editor/src/prototype/undo.ts (sameEndpoint, lines 99–105) compares only Y relative positions whenever both endpoints have gaps. The separator test in undo.test.ts shows that the end of owner a and the start of owner b can share a native gap while remaining distinct points. The typing coalescing check (undo.ts, lines 153–159) can therefore group a second action after that cursor move into the first action. One undo then removes both edits and restores the first action's earlier selection. Preserve the structural endpoint fields in the gap case and cover typing across the two separator sides.
  • P3: none.

The Rust insertion-span and Yrs root-materialization changes are present at the edit and replay paths. Per-device action stacks and reducer actor checks implement K1. Cross-device tests exercise reversed delivery, partial delivery/restart, and preservation of remote text as a separate block after creation undo. I found no additional issue in those paths.

Verdict: fix first.

Independent review, round 1 - P0: none. - P1: none. - P2: `packages/editor/src/prototype/undo.ts` (`sameEndpoint`, lines 99–105) compares only Y relative positions whenever both endpoints have gaps. The separator test in `undo.test.ts` shows that the end of owner `a` and the start of owner `b` can share a native gap while remaining distinct points. The typing coalescing check (`undo.ts`, lines 153–159) can therefore group a second action after that cursor move into the first action. One undo then removes both edits and restores the first action's earlier selection. Preserve the structural endpoint fields in the gap case and cover typing across the two separator sides. - P3: none. The Rust insertion-span and Yrs root-materialization changes are present at the edit and replay paths. Per-device action stacks and reducer actor checks implement K1. Cross-device tests exercise reversed delivery, partial delivery/restart, and preservation of remote text as a separate block after creation undo. I found no additional issue in those paths. Verdict: fix first.
Author
Owner

Review round 1 P2 addressed in f88c3478.

Typing coalescing now compares structural endpoint identity (note, owner, order, boundary, side and affinity) before comparing Yjs relative positions. Typing across block owners or opposite separator sides starts a new undo group, so undo restores the caret from that group's own before position.

Added regression coverage in the Rust prototype and TS adapter. The TS regression failed against 4559b1dd by undoing both edits and restoring the first block; it passes with the fix.

Dev-02 gates: undo768 5/5, review758b 5/5, review758b_minimal 2/2, structured 6/6, Rust separator regression 1/1, TS adapter tests 11/11.

Review round 1 P2 addressed in `f88c3478`. Typing coalescing now compares structural endpoint identity (note, owner, order, boundary, side and affinity) before comparing Yjs relative positions. Typing across block owners or opposite separator sides starts a new undo group, so undo restores the caret from that group's own before position. Added regression coverage in the Rust prototype and TS adapter. The TS regression failed against `4559b1dd` by undoing both edits and restoring the first block; it passes with the fix. Dev-02 gates: `undo768` 5/5, `review758b` 5/5, `review758b_minimal` 2/2, `structured` 6/6, Rust separator regression 1/1, TS adapter tests 11/11.
Author
Owner

Long crate gate result for PR #816

  • Tested head: 4559b1dd2c05641e42e4451b5ecee97af4e8001d.
  • Result: PASS (1 passed; 0 failed; 0 ignored).
  • Command: cargo test -p calternal-block-ids --test verify5 -j4 -- --include-ignored independent_seeded_runs, run through ~/bin/slot inside nix develop in ~/Developer/Worktrees/undo-768.
  • Duration: 18,787.48 seconds (5 hours 13 minutes 7.48 seconds).
  • Seeds: VERIFY5_SEED and VERIFY5_RUNS were unset, so defaults applied: seed start 0, 300,000 runs, seeds 0 through 299,999 inclusive.
  • Systemd: Result=success, exit status 0; unit inactive/collected. The run completed below the 43,200-second runtime limit.
Long crate gate result for PR #816 - Tested head: `4559b1dd2c05641e42e4451b5ecee97af4e8001d`. - Result: PASS (`1 passed; 0 failed; 0 ignored`). - Command: `cargo test -p calternal-block-ids --test verify5 -j4 -- --include-ignored independent_seeded_runs`, run through `~/bin/slot` inside `nix develop` in `~/Developer/Worktrees/undo-768`. - Duration: 18,787.48 seconds (5 hours 13 minutes 7.48 seconds). - Seeds: `VERIFY5_SEED` and `VERIFY5_RUNS` were unset, so defaults applied: seed start 0, 300,000 runs, seeds 0 through 299,999 inclusive. - Systemd: `Result=success`, exit status 0; unit inactive/collected. The run completed below the 43,200-second runtime limit.
Author
Owner

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

restacked undo fixes with #758/#768. targeted unit and regression suites are planned; the historical five-hour verify5 run is not included.

head: 6a25827d4ff300d8035623e8b9b3f3226ccbfdd4, 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; cargo test -j4 --locked -p calternal-block-ids --test undo768 --test review758b --test review758b_minimal --test structured, including the deep random separator-history regression. frontend inputs are unchanged since the initial frontend pass. commands and logs.

this is prototype/package validation. historical five-hour verify5 qualification, fuzzing and performance qualification were not rerun; no merge or production-readiness claim. original CR/CRLF fuzz fixture bytes were retained.

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

housekeeping #1009: rebased+green for the targeted gates below, left open for review. restacked undo fixes with #758/#768. targeted unit and regression suites are planned; the historical five-hour verify5 run is not included. head: `6a25827d4ff300d8035623e8b9b3f3226ccbfdd4`, 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`; `cargo test -j4 --locked -p calternal-block-ids --test undo768 --test review758b --test review758b_minimal --test structured`, including the deep random separator-history regression. frontend inputs are unchanged since the initial frontend pass. [commands and logs](https://git.kayg.org/attachments/d9719359-7d60-4373-a33f-47df827f1dee). this is prototype/package validation. historical five-hour verify5 qualification, fuzzing and performance qualification were not rerun; no merge or production-readiness claim. original CR/CRLF fuzz fixture bytes were retained. [original-head patch inventory](https://git.kayg.org/attachments/e05a38dc-c028-4d77-8655-efa9d5c8ea50), `pr-816.md`.
Author
Owner

Parked (14 Nov housekeeping, #1106 triage comment). dev has no crates/block-ids. The perf VM failed Enter at +1.785 ms p95 (gate: 1 ms), and load/sync is superlinear (10k notes: 166 ms). Left open on purpose; confirm any fix on the perf VM, not the build host.

**Parked** (14 Nov housekeeping, [#1106 triage comment](https://git.kayg.org/kayg/calternal/issues/1106#issuecomment-95950)). dev has no `crates/block-ids`. The perf VM failed Enter at +1.785 ms p95 (gate: 1 ms), and load/sync is superlinear (10k notes: 166 ms). Left open on purpose; confirm any fix on the perf VM, not the build host.
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'fix/undo-768:fix/undo-768'
git switch 'fix/undo-768'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'proto/block-identity-v7d'
git merge --no-ff 'fix/undo-768'
git switch 'fix/undo-768'
git rebase 'proto/block-identity-v7d'
git switch 'proto/block-identity-v7d'
git merge --ff-only 'fix/undo-768'
git switch 'fix/undo-768'
git rebase 'proto/block-identity-v7d'
git switch 'proto/block-identity-v7d'
git merge --no-ff 'fix/undo-768'
git switch 'proto/block-identity-v7d'
git merge --squash 'fix/undo-768'
git switch 'proto/block-identity-v7d'
git merge --ff-only 'fix/undo-768'
git switch 'proto/block-identity-v7d'
git merge 'fix/undo-768'
git push origin 'proto/block-identity-v7d'
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!816
No description provided.