Notes fuzz: "history write failed" under load (flaky, durability question) #652
Closed
opened 2026-10-20 21:58:55 +00:00 by kayg
·
171 comments
No Branch/Tag specified
main
port/tasks-float-2
fix/train-1116-2
fix/train-1116-3
fix/train-1116-1
fix/flake-1134
fix/server-1182
dev
port/notes-float-3c
docs/auto-update-ig
feat/dav-transport
port/tasks-float-1
wip/mail1011-sv-order-1116
fix/flake-1179
fix/flake-1178
fix/guards-1153-fsio-split
fix/guards-1153-notes-split-we
fix/guards-1153-notes-lib
fix/guards-1153-notes-home
fix/guards-1153-ui-primitives
fix/guards-1153-primitives-e2e
fix/guards-1153-visibility-doc
feat/paper-grey-1116
fix/flake-1165
fix/flake-1119
docs/imap-766-plan-v2
fix/e2e-unique-ports
t3/paged-search-reconcile-final
wip/mail1011-final-1115
docs/tasks-float-port
perf/editor-first-paint-1c
feat/imap-notes-fetch
feat/imap-notes-projection
feat/imap-notes-readonly
feat/imap-notes-auth
feat/imap-notes-server-foundation
wip/mail1011-txn-ownvocab-1115
wip/mail1011-txn-novocab-1115
perf/p1117-final-harness
perf/single-shot-repeats
port/tasks-matrix
wip/mail1011-txn-1115
fix/static-gates-1155
feat/files-s1-identity-r7
fix/files-r7-idle-loop
fix/daily-train-1152
port/notes-float
fix/editor-tables-test-types
port/notes-float-listscript
feat/tasks-actions
port/notes-float-phone-preload
perf/sound-comparator
port/notes-float-listscroll
port/notes-float-budgets
port/notes-float-suite-fix-b
port/notes-float-sidebar-fix
port/notes-float-trim
port/notes-float-3-lists
fix/attachments-meta-capability
docs/carddav-writes-v2-plan
feat/contacts-companion-pure
issue/carddav-read-perf-fix-r2
issue/carddav-read-r2
port/notes-float-devsync2
review/calendar-2
review/switcher-a-pills
port/notes-float-switcher-a
port/port-tables-2
review/switcher-ends
wip/whiteboard-s1-1114
port/port-tables
wip/mail1011-perfneutral
review/photo-tint
port/notes-float-shell
wip/local/collections-db
wip/local/mail-p1
wip/local/cold-growth-on-tiering
wip/local/tiering-v3-s1
wip/local/wal1051-cap
wip/local/tiering-v3-s1-resume
wip/local/index-position-startup-scan
port/notes-float-flat
port/notes-float-promote
wip/handover/mail1011-candidate
wip/handover/files-s1-candidate
port/notes-float-shell-only
port/notes-float-perf
feat/whiteboard-s1
feat/tiering-v5
fix/app-switch-hitch
wip/local/files-s1-dev-v4-final
feat/files-s1-dev-v4
fix/c2-glass-shared
feat/flat-lists
wip/handover/whiteboard-s1-resume
wip/att-lazy-861
feat/switcher-browse
wip/att-lazy-860
feat/tasks-float
recovered/flat-backup-candidate
perf/stalls-1054-kc
land/ai-toolbar
feat/collections-db
feat/collections-db-fixes
codex/mail-1011-redesign-20261111
fix/ai-toolbar
backup/macos-vm/st3-head
perf/trim-candidate-phonestack
feat/switcher-three
fix/1051-index-idle-checkpoint
perf/stalls-1054-kb
perf/stalls-1054-k
perf/stalls-1054-r3
fix/c2-contrast-tail
perf/stalls-1054-r3-preview
feat/collections-before
feat/tiering-v4
fix/timelog-caret
wip/local/tasks-actions
docs/tasks-writes-v2-plan
st3-r3
feat/pass8
review/calendar-2-before-1111
wip/tiering-v3-cold4
perf/stalls-1054-r2
fix/suite-A4
fix/suite-A5-probe
fix/suite-A6
fix/suite-A3
fix/suite-A2
fix/suite-A5
fix/suite-A1
wip/local/attachments-861-fix
feat/contrast
wip/local/ports-861
storage/wal-checkpoint-off-save-1051
wip/local/mail-1011-reconcile-20261110
feat/style-sheet-fixes
feat/money-round
perf/stalls-1054
wip/tiering-v3-cold5
t3/mail-1011-liveness
feat/iphone-fixes
feat/notes-approve
wip/local/shrow-work
feat/files-s1-identity
feat/quickfix
wip/tiering-v3-cold
wip/local/shared-row-swipes
backup/macos-vm/pfx-B
backup/macos-vm/pfx-C
backup/macos-vm/pfx-D
feat/contrast-r1
feat/tiering-v3-s2-tags
feat/folder-drop
t3/photos-s1
feat/tiering-v3-s1-namespace
wip/local/photos-s1
t3/photos-plan-slice-one
recovered/backup/p1b-61505
t3/paged-search-reconcile
t3/smooth-pane-transitions
t3/index-position-startup-scan
fix/private-staging-759b-r2
backup/macos-vm/hk/hk1009/pr877
backup/macos-vm/hk/hk1009/pr878
docs/undo-block-ids-plan
fix/undo-768
backup/macos-vm/hk/hk1009/pr875
backup/macos-vm/hk/hk1009/pr904
proto/block-identity-v7d
backup/macos-vm/hk/hk1009/pr846
backup/macos-vm/hk/hk1009/pr860
backup/macos-vm/hk/hk1009/pr861
backup/macos-vm/hk/hk1009/pr849
backup/macos-vm/hk/hk1009/pr848
backup/macos-vm/hk/hk1009/pr853
backup/macos-vm/hk/hk1009/pr957
backup/macos-vm/hk/hk1009/pr893
backup/macos-vm/hk/hk1009/pr889
backup/macos-vm/hk/hk1009/pr902
docs/imap-notes-plan
docs/quota-plan-2
fix/parallel-test-flakes
docs/calendar-backend-v2-plan
feat/calendar-ical-converter
backup/macos-vm/hk/hk1009/pr808
docs/contacts-import-v2-plan
issue/610-pm-midnight
feat/calendar-v2-s1-containment
backup/macos-vm/hk/hk1009/pr854
backup/macos-vm/hk/hk1009/pr845
backup/macos-vm/hk/hk1009/pr917
docs/dav-recorder-v2-plan
plan/previews-865
plan/save-log-durable-entry
backup/macos-vm/hk/hk1009/pr934
fix/e2e-data-on-ram
backup/macos-vm/hk/hk1009/pr888
feat/appwindow3
feat/appwindow2
feat/appwindow
feat/money-p1
feat/keys-sheet
review/calendar-2-themes
feat/smooth-cursor
fix/float-style
review/calendar-2-float
release/2026-11-06-hotfix
archive/port/rows-drop-code
archive/port/rows-actions
archive/port/rows
scratch/tasks-894-ui-gates
review/calendar-2-night-wip
recovered/flaky/toast-reduced
release/2026-11-05
archive/flaky/rows-drop-fixed
archive/flaky/rows-actions
archive/flaky/rows
sim/bm15-final
sim/bm15-bis-932
sim/bm15-bis-909
sim/bm15
sim/bm15-bis-887
perf/tiering-option-b
fix/sw-lazy-precache
archive/plan/save-log-durable-entry
mock/money-fix2
archive/fix/e2e-data-on-ram
mock/appearance-all
mock/pill-press
mock/pill-press-mac
backup/macos-vm/appearance-after
mock/auto-swipes
mock/mail-actions
backup/macos-vm/mock/mail-actions
mock/money-static
archive/review/standards-917
perf/tiering-761-fix
mock/type-audit
mock/third-pane
feat/contacts-import-v2-s1
perf/executor-hot-path
archive/port/hidden-blocks
archive/port/devices
scratch/executor-on-894
scratch/executor-spans2
scratch/executor-spans
archive/port/rows-drop
feat/tiering-761-d-scale
feat/tiering-761-c-index
feat/tiering-761-b-reader
archive/review/sharing-pr3-review-9fec3d1f
perf/ports-lazy-budgets
feat/tiering-761-a-migration
archive/review/sharing-pr3-review
archive/review/sharing-pr3-review-code
archive/plan/previews-865
archive/port/port-attachments-3
archive/port/contacts-merge
fix/motion-audit-859
fix/motion-audit-859-mac
archive/port/port-pickers
archive/port/port-tables-2
archive/port/port-tables
recovered/local/sharing-s1-pr2-room-snapshot-candidate
archive/fix/parallel-test-flakes-code-minipc01
docs/imap-766-readonly-slice
feat/dav-recorder-v3
research/788-diagnosis
archive/fix/parallel-test-flakes
archive/perf/pr792-cold-index-edit
docs/sharing-slice-1
recovered/feat/dav-recorder-v2
recovered/feat/dav-recorder-v2-edd7bbb
spike/imap-766-s0-cases
archive/fix/undo-768
recovered/feat/dav-recorder
recovered/feat/dav-recorder-901acd4
feat/contacts-import
perf/cold-growth-on-764
perf/cold-growth-on-tiering
recovered/feat/tasks-set-status
feat/tasks-move-reorder
feat/tasks-delete-promote-duplicate
feat/carddav-writes
perf/quota-on-tiering
perf/quota-simple
perf/cold-growth-on-quota-stack
recovered/perf/cold-growth-on-tiering
feat/calendar-identity
feat/calendar-event-parser
feat/calendar-props-maps
port/glass-when-ring
recovered/feat/tiering-761-s1-wip-8132a84
recovered/feat/tiering-761-s1-wip-9da4094
recovered/feat/tiering-761-s1-wip-724512c
recovered/feat/tiering-761-s1-wip-66e667e
recovered/feat/tiering-761-s1
wip/6by32-01-tier-761-s1-pause-20261030
spike/imap-766-s0
wip/6by32-02-calternal-pause-20261030
wip/8by64-01-review-688-pause-20261030
wip/6by32-01-verify-744-pause-20261030
wip/6by32-01-verify-742-pause-20261030
fix/private-staging-759b
wip/6by32-01-review-748-pause-20261030
wip/6by32-01-review-733c-pause-20261030
wip/6by32-01-review-733b-pause-20261030
review/calendar-month
wip/local/bm15-trash
plan/759b-staging
review/767b-tests
review/preview-2026-10-29
docs/tiering-731-plan
wip/c6b02-review-733d
wip/c6b02-bm1-full-a
docs/deploy-plan
fix/storage-owner-liveness-642
fix/storage-fix-7
feat/tiering-731
wip/tiering-731-first-attempt
perf/idle-honest-2
fix/storage-private-tmp-642-dev
fix/storage-exact-file-quarantine-642
perf/one-flush-save
review/calendar-static
review/indexing-ring
review/when-field-2
proto/block-identity-2-review
proto/block-identity-review
review/when-field
issue/tasks-create-ids
issue/tasks-create
review/combined
review/task-polish
review/top-buttons
review/q1-q5
archive/integ325-293
archive/integ325-ci
issue/calendar-adr
archive/old/train/2026-10-23bk2
archive/old/train/2026-10-23bk
issue/469-mockup-9a
issue/smart-tasks-mockup
issue/469-menus
issue/652-signout-flake
issue/652-history-fix7
issue/652-history-fix6
archive/old/issue/spring-check-perf
issue/spring-check-perf
issue/659-rename-fast
archive/old/train/2026-10-21ar
issue/search-hardening-3
issue/652-history-fix5
issue/660-port-sheets-glass
issue/652-history-fix4
issue/652-history-fix3
issue/652-history-fix2
issue/652-history-flake
train/2026-10-21an
issue/settings-admin-port
issue/search-port
train/2026-10-20am
issue/storage-split-fix2
issue/storage-split
archive/old/issue/folder-ids-fix
train/2026-10-20al
archive/old/issue/folder-ids
train/2026-10-20ak
issue/tables-mockup
train/2026-10-19aj
train/2026-10-19ai
issue/469-merge-fixes
issue/sidebar-band
archive/old/issue/608-settings-spec
train/2026-10-19ah
issue/swipe-offscreen
train/2026-10-19ag
archive/old/issue/590-nlp-adr
archive/old/issue/587-event-after-write-2
train/2026-10-19af
archive/old/issue/587-event-after-write
issue/469-pill-room-c
issue/469-pill-room
train/2026-10-19ae
issue/469-narrow-handle
issue/397-ios-swipe-2
issue/469-desk-fixes
archive/old/issue/auto-update-adr
issue/469-filter-gap
issue/469-port-1b
issue/442-opacity-flake
issue/327-web-fast-3
archive/old/issue/469-port-1
issue/469-port-1
issue/327-web-fast-2
archive/old/issue/327-web-fast
archive/old/issue/425-stt-bench-vq1
archive/old/issue/445-no-bleed
archive/old/issue/400-swipe-mockup-2
issue/426-client-review
issue/426-client-2
issue/426-client
archive/old/issue/476-safe-area-lab
archive/old/issue/445-top-light
issue/471-blocks-mockup
archive/old/issue/448-links-app-2
archive/old/issue/448-links-app
archive/old/issue/398-cold-links
issue/434-442-small-2
issue/434-442-small
archive/old/issue/398-unload
archive/old/issue/445-bottom-band
issue/445-bottom-band
issue/351-rem-3
issue/351-rem-2
issue/351-rem
archive/old/issue/327-first-note
issue/395-width-phone
archive/old/issue/327-typing
issue/396-ios-edges
issue/397-ios-swipe
archive/old/issue/327-notes-index
issue/345-347-contrast-empty-2
archive/old/issue/44-arenas
issue/44-arenas
archive/integ325
archive/old/issue/327-perf-harness
archive/old/issue/44-thp
issue/44-thp
archive/old/issue/285-sticky-pills
archive/old/issue/44-trim-3
issue/44-trim-3
archive/old/issue/165-cards
archive/old/issue/165-picker-2
archive/old/issue/212-multi-select
No results found.
Labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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#652
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Seen 2026-10-21 in an unrelated job's workspace run (vcard-fix4, branch issue/645-vcard-format3, base origin/dev after train AM), passed on focused and full reruns:
A history write failing is a durability question (typing acks mean "the change is in history"), not just a flaky test. Find the root cause: what error hides behind "history write failed" (SQLITE_BUSY, disk full on the test tmpfs, a lock timeout, a race with restart in the fuzz), whether production can hit it, and what the user sees if it does.
Starting unattended investigation on branch issue/652-history-flake, base
6ac345ace7. I will reproduce under load, expose the internal source error safely, add a deterministic regression, run the requested gates and push this branch only. No PR, merge or deployment. Artifacts remain outside the repository.Second sighting, probably the same family (coordinator, 2026-10-21): train AO (
80f0516= dev + crates/contacts only, no notes/server change) failed its workspace tests incrates/calternal/tests/notes_crash.rs:156kill_nine_never_loses_or_doubles:An internal 500 on a save under load right after a kill -9 restart. Include this test in the investigation: find which internal error produced the 500 and whether it is the history writer.
Finding: the source error is lost in every history write. In crates/notes/src/history.rs, commit logs begin/job/commit errors and drops reply senders; History::write and append map the canceled receiver to the same "history write failed" detail. The issue's old panic therefore cannot identify its original SQLite cause. The writer already uses BEGIN IMMEDIATE and a 5-second busy timeout, so adding another speculative timeout is not justified.
The host currently has a 1024-descriptor soft limit and /tmp was 97% full at investigation start (1.1 GiB free); neither proves the historical cause. I am testing resource exhaustion separately from CPU contention. A permanent regression now injects SQLITE_FULL with SQLite's max_page_count quota, without filling shared storage, and requires the original cause to reach the internal error detail. Client adapters use the error code's catalogue message; internal detail is for logs only.
CLAUDE.md is absent from this checkout and its ancestor directories; there is no tracked CLAUDE.md or AGENTS.md. I read CONTEXT.md and ADRs 0020/0021 for the durability contract. All build work is queued through the required build-slot wrapper. No production machine is involved.
Execution is temporarily blocked on the shared build slots: all three are held by other jobs. The baseline and regression command is waiting through /home/kayg/codex-jobs/_lib/build-slot.sh. I am continuing code and durability-path inspection while it waits. I will not bypass the slots or stop other jobs. I also corrected this unattended shell's missing Cargo PATH by selecting the repository-pinned 1.99.0 toolchain bin directory explicitly.
I found the original job transcript at /home/kayg/codex-jobs/vcard-fix4/log.txt. Its failed workspace run ended with 309 notes tests passed, one failed, one ignored, in 18.92 seconds. The fuzz reported completed seeds 1 through 21, then the generic internal error at review.rs:24:41. The captured failure contains no SQLite source error or history transaction log. This confirms that the historical trigger cannot be recovered from that transcript; I will distinguish any new reproduction from that historical uncertainty rather than name a guessed SQLite cause.
Static inspection found a durability gap worth testing independently: commit_local and outside ingest change the live CRDT before waiting for history, and a failed write neither advances the applied counter nor retains that diff in the in-flight queue. A later save check can therefore consider the live state already durable. The new disk-quota regressions check the actual outgoing Saved reply and history replay after recovery for both paths. They still await a build slot. The shared train marker is active, so the slot wrapper correctly gives the train priority.
Execution status: the corrected baseline command has now waited about 28 minutes inside the required build-slot wrapper. /tmp/calternal-train.active points to a live train runner, so non-train commands correctly wait. The train's slot owners are changing, which indicates progress rather than a stale lock. I have not bypassed the slots or touched other jobs. The perf VM lock is also occupied. No Rust build or test has started for this investigation yet; the test changes and implementation are prepared, and I am waiting for the failing-test evidence before applying product changes.
For the final gates I chose a separate healthy temp directory under /dev/shm, while keeping the nearly full filesystem experiment in a private mount namespace. This separates expected storage-exhaustion reproductions from the required zero-failure load gate. All evidence remains outside the repository.
The lightweight SQLite fault-injection preflight succeeded on a fresh database in healthy /dev/shm. Capping max_page_count at its current size and inserting a 1 MiB blob produced this exact output:
No shared filesystem was filled. This verifies the mechanism used by the permanent Rust regressions; it does not establish the historical fuzz trigger. Rust execution remains queued behind the active train. The prepared diagnostics preserve SQLite's extended error code too, because the display message alone cannot distinguish individual I/O failures.
Finding from the required client-privacy check: HTTP/websocket error bodies already omit Error.detail, but failed bulk jobs are another route. In crates/notes/src/bulk/mod.rs, drive assigns why.detail to body.error and report copies that field into the client-visible Report. Expanding history diagnostics without addressing that route could expose server diagnostic text through notes.job.
I added a deterministic regression that runs a real failed edit job, verifies that its returned server error retains the source detail, then requires the stored client report to contain only the error catalogue message. The prepared change stores that safe message when a job fails. It does not change HTTP error formatting. The regression still awaits the build slot, so this is code evidence, not a claimed passing gate.
The baseline has now waited about one hour through the required wrapper. The train's last child is an active WebKit run, currently about 21 minutes into its own 4,200-second timeout. This is not a stale priority marker. I have left the marker, locks and all other jobs' processes alone and will continue waiting. No Rust gate has started, so there is no passing result to report yet.
The test-only diagnostics now print begin/statement/commit failures into captured test output, including failures that a retry recovers. The load harness also records peak descriptors for each child and records every PID it starts. These are test code and external diagnostic artifacts, not committed measurement reports.
Confirmed deterministic failures on the unchanged product code:
The original fuzz passed all 24 seeds, 2,424 saves and 264 restarts in 16.93 seconds. The new page-quota regression then logged the real source
history: statement failed: database or disk is full, while its caller received onlyError { code: Internal, detail: "history write failed" }(0 passed, 1 failed).Both protocol regressions failed (0 passed, 2 failed). After a failed already-applied server edit or outside edit, a joining browser receives the changed live document and can immediately receive Saved although the change is absent from history. The assertions were
failed history must never receive Savedandfailed outside history must never receive Saved. This is P1 under the ADR: it can happen in production during storage exhaustion, rather than being only a test panic. Browser typing itself normally retries through the in-flight queue; these other live edit paths did not retain failed diffs or count them as pending durability work.Both report-privacy regressions also failed (0 passed, 2 failed). For example, the public job report returned
version -652 doesn't exist (latest is 1)rather thanSomething in that request doesn't look right.The legacy fixture also exposed its stored server path.I am applying the prepared source-error propagation, durability-queue and report-privacy changes now. The copied old binary is independently running 20 serial fuzz iterations under eight CPU load workers before the isolated low-space filesystem experiment. This does not yet establish the historical flake's trigger.
Reproduction results on the original product code:
One low-space run produced this exact source and caller output:
This is a real filesystem SQLITE_FULL failure at COMMIT hidden behind the same generic history error, rather than only a simulated callback failure. Storage exhaustion is production-reachable. The deterministic page-quota regression reproduces the same SQLite error class without filling any filesystem; the deferred-constraint regression covers failure specifically at COMMIT.
The historical occurrence still cannot be uniquely assigned to disk-full because its source was discarded and its captured transcript has no transaction diagnostics. The experiment establishes a concrete reproducible cause, and the fix retains sources for future failures instead of guessing that CPU load requires a longer busy timeout. The five failing protocol/privacy regressions documented above are independently confirmed production correctness defects.
The fixed-code checks passed. The seven history unit tests passed, including deterministic SQLITE_BUSY at BEGIN, a group-wide statement rollback, a deferred foreign-key failure at COMMIT, and SQLITE_FULL followed by recovery. The two previously failing Saved regressions now pass: no reply during failed history, then the exact Saved packet after recovery, with history replay equal to the live document. Both new and legacy job-report privacy tests also pass.
Representative internal diagnostic output now retains the phase, message and SQLite code:
A complete fuzz run also passed with a deliberately reduced 128-descriptor limit both before and after the fix. The normal loaded baseline's 20 runs peaked at 24 descriptors, so descriptor exhaustion was not observed in these experiments. The 1 MiB-free private tmpfs still correctly refuses writes; it is an intentional resource-failure reproduction, not a passing-storage gate.
The required format, all-targets workspace Clippy, full workspace tests and 200 complete loaded fuzz runs are now starting in the same admitted build slot. No gate completion is claimed yet.
The first full format, Clippy and workspace test gates all passed. I interrupted its load gate after the descriptor monitor falsely marked successful fuzz processes as failed: the Rust logs showed
test result: ok. 1 passed; 0 failedfollowed by the monitor's own/proc/<pid>/fdpermission error during process exit. Descriptor sampling is now best-effort and cannot change a test's outcome. The interrupted attempt endedGATES fmt=0 clippy=0 workspace=0 loaded_loop=143; it is not being counted as a passing final gate. Only this job's recorded harness PID was stopped, and its own CPU workers were cleaned up.Review of the recovery path also found that keeping a failed live diff for retry is insufficient if existing peers never receive it. I extended both disk-full protocol regressions with an already connected replica and save check. Both failed deterministically with:
The recovery change now sends the already-applied diff to peers even when history fails, like typing already does, while retaining it in the durability queue and holding Saved until commit. Healthy server edits still broadcast after commit. The expanded tests also reconstruct the peer from the actual protocol update and require its text to match the live document. I am verifying this change before rerunning all final gates.
Finished on branch issue/652-history-flake, head
389da8f1a6. The branch is pushed. No PR, merge or deployment was performed; the issue stays open.A nearly full private tmpfs reproduced the hidden history failure as SQLITE_FULL (DiskFull, extended code 13) at COMMIT: 5/5 failed before and 5/5 correctly refused writes after the fix. Healthy storage under load passed 20/20 baseline runs and 200/200 final runs (0% final failure rate). The final gate used eight CPU load workers and up to four concurrent complete fuzz processes. Observed peak descriptors per child: 27; fuzz logs containing transaction failures: 0. A complete run also passed with a 128-descriptor limit before and after the change.
The historical event cannot be uniquely attributed to disk-full: its source was discarded and the original transcript has no SQLite error. No evidence justified increasing the existing five-second busy timeout.
The production defect is fixed: already-applied server/outside changes that fail history stay in the retry queue, reach connected peers, and keep Saved unanswered until committed. This prevents a joining browser from accepting unjournaled state as saved. During an outage clients wait for Saved and API callers can receive a retryable error; storage must recover before saving can finish. Sources now retain the transaction phase and SQLite primary/extended code internally. New and old job reports return only safe catalogue messages.
Eight permanent deterministic regressions cover disk-full/recovery, transaction begin/statement/commit failures, both peer-and-Saved paths, and both job-report privacy paths. No evidence, logs or generated artifacts were committed.
Final gate output follows verbatim:
Independent unattended review started. Worktree /home/kayg/Developer/calternal-wt-histrev; review branch issue/652-history-flake (checkout ); head
389da8f1a6; base origin/dev6ac345ace7. Reviewing git diff origin/dev...389da8f. Scratch tests only; no commits or pushes. Will test failure recovery, peers, ordering, queue bounds, crash load and before/after save latency.Review progress: the assigned head has built successfully (cargo test -p calternal --test notes_crash -j4 --no-run, exit 0; 3m 18s). Execution of the independent fault tests, real SyncClient checks, latency comparison and 50 loaded crash runs is temporarily waiting for a shared build slot; all three slots are occupied by other jobs. I am keeping the wrapper and waiting, without bypassing admission or stopping any other job. Static review identified a possible browser confirmation gap in SyncClient.remoteConfirmed; I have prepared a test using actual failed-history protocol packets before treating it as a confirmed finding.
P1 finding from code review: peers still treat live, unjournaled state as saved in the real browser client.
The new failure paths in crates/notes/src/room/merge.rs:44-55 and :99-107 send the applied update to peers before history succeeds. However, packages/editor/src/sync/client.ts:189-203 applies both joining snapshots and live updates and calls remoteConfirmed(). At :225-226, that function immediately calls onConfirmed when this device has no local pending changes; no history receipt is required. Remote updates do not enter the pending counter (:137-146), so the status can remain Saved. packages/editor/src/note.ts:170-180 then stores that text as the safe replay base after 100 ms.
The server-side tests only verify that a requested Saved packet is withheld. They do not exercise SyncClient and therefore do not establish the claimed peer guarantee. A joining or idle connected browser can accept the changed live text as confirmed despite receiving no Saved packet for it.
I have prepared scratch tests that capture the actual Rust packets under SQLITE_FULL and feed them into the unchanged TypeScript SyncClient. Their execution is waiting for a shared build slot. This is currently a static finding; I will append the execution results before the final verdict.
The P1 peer finding is now reproduced with the actual Rust failure packets, not only inferred from source. A scratch Rust test forces SQLITE_FULL on a 128 KiB server edit, captures the update sent to an existing peer and the full snapshot sent to a joining browser, and confirms neither receives Saved. Those exact byte packets are fed into unchanged copies of this head's SyncClient and protocol code, using the installed Yjs 13.6.33.
Verbatim observations:
Reproduce: after running the independent Rust tests,
bun test scratch/editor-peer/peer.test.ts. The two additional synthetic tests fail in the same way. The important assertions fail on Saved itself; the logged callback counts independently show that the unsafe snapshot is also considered confirmed. This violates the claimed peer guarantee and affects the new failed server/outside edit broadcasts. The server-side Saved regressions still pass, demonstrating why testing only the packet release is insufficient.P1: retrying the oldest edit does not preserve history order against later submitted edits.
Reproduction:
cargo test -p calternal-notes -j4 independent_652_failed_first_typed_edit_must_precede_second -- --nocapture. Create a note and settle it, cap the writer's max_page_count at page_count, type a 128 KiB first change and wait for that transaction to fail, then type a small second change from the same Yjs document. The second write fits an existing page and commits while the first remains in the retry queue. Lift the quota and settle the room.Verbatim result:
The final replay text equals the live document, but history order is wrong: the earlier version contains an update dependent on a change that only appears in a later version. The room pops acknowledgments in order, but queue_local in crates/notes/src/room/pipeline.rs:72-77 immediately submits later edits to the writer, while rewrite_front resubmits the failed first edit later. Ordering a room's receipt deque does not order those database commits. This is a surviving gap in the existing typing pipeline, not a newly introduced typing regression. It fails the change's stated in-order recovery contract.
P2 contract gap: the server's retry queue does not survive SIGKILL; recovery needs an explicit client resend.
Reproduction:
cargo test -p calternal-notes -j4 independent_652_queued_api_survives_kill9 -- --nocapture. The child creates and saves a note, sets a SQLite page quota, applies a 128 KiB API append with a stable key, verifies the API returns an error and the edit is still in flight, and announces readiness. The parent sends SIGKILL to that recorded child, restarts on the same data and state, reads the note, then explicitly retries the same key twice.No acknowledged edit is lost in this test. The client receives a retryable failure, and same-key replay works exactly once. However, the literal claim that queued edits themselves recover across kill -9 is stronger than the implementation: retain_local stores the diff only in Room.inflight (pipeline.rs:92-98), and startup reconstructs from committed updates and files, with no persistent queue to reload. This matches ADR 0020's client-replay model; it does not meet automatic queue survival without a retained caller. The contract should explicitly require client replay, or the implementation needs a durable recovery source. This distinction is why the scratch assertion for autonomous queue recovery fails.
P2: the typed edit queue is capped by count, but save-check requests accumulate without a bound during an outage.
Reproduction:
cargo test -p calternal-notes -j4 independent_652_outage_queue_and_save_checks -- --nocapture. With SQLite quota exhaustion held active, queue 1,024 edits. The next edit fails before being applied, so the edit limit works and that next edit stays on the client. A joined peer can then send 10,000 valid custom message 100 save checks through Room.message. No Saved packets are emitted and all 10,000 PendingAck values remain stored.acks.rs:52-58 pushes each check without a limit or coalescing; :70-75 scans and rebuilds the whole waiting list on every check. A connected protocol client can grow memory without limit and drive quadratic work while history is unavailable. This is an existing resource-bound gap left by the change, not a newly introduced regression. Normal typing has a 1,024-item limit, the room input has a 4,096-command buffer, and client output has a 1,024-message buffer; those limits do not bound PendingAck. The test uses a burst of requests while the outage remains active rather than waiting hours. The user sees no Saved answer during that period; local pending edits show Saving while connected, or Not saved yet with an age after disconnect.
P2: the required loaded crash gate is not consistently green on this head.
Run 13 of the requested 50 serial executions of crates/calternal/tests/notes_crash.rs::kill_nine_never_loses_or_doubles failed under two background CPU workers. Verbatim output:
This is the final notes.save status assertion after the final content and duplicate checks. It is a 503, not the train's reported 500, and it does not by itself demonstrate lost or doubled acknowledged edits. The test discards that response body and suppresses server stderr, so this output cannot establish the internal cause or attribute it to this diff. The original 50-run loop is continuing to completion; I will report the final count and any 500 observations separately. Gate logs are kept outside the repository.
The requested 50 loaded crash runs are complete: 49 passed, 1 failed (run 13, final notes.save returned 503). Two nice-19 CPU workers ran throughout the loop and consumed 497.070 CPU-seconds. No assertion with actual status 500 appeared in the captured logs, so the train's reported 500 was not reproduced. The original test suppresses server stderr, discards the final save error body, and treats a streaming request failure as an in-flight edit to retry, so these logs do not observe every HTTP error or establish the 503's source.
Per-edit healthy save latency was measured through the public Notes.edit API, from append submission to its durable receipt. Same source benchmark, same dev profile, same target directory and host; 200 warmups then 2,000 sequential edits per run; four alternating-order pairs; 8,000 measured edits per revision. This review's CPU workers had stopped before timing. The baseline fixture matches fixed base
6ac345ace7.389da8fThe head's pooled p50 is 9.1% higher and p95 is 4.0% higher in this sample. The shared host is noisy and the paired results vary; this does not isolate a causal production slowdown. It does not establish the claimed absence of added latency either.
An initial comparison was discarded after SHA-256 verification showed Cargo had reused one executable for both labels in the shared target directory. Those initial LATENCY lines are invalid. The corrected run cleans only calternal-notes artifacts before each build, copies each executable, verifies different hashes, and uses the VERIFIED_LATENCY and PER_EDIT_LATENCY lines. The baseline binary lacks the new history error marker and the head binary contains it, providing a further check that the intended source change is present only in the head measurement. All raw samples and gate logs remain outside the repository.
Independent review finished. Verdict: do not merge.
Reviewed head
389da8f1a6, change identified as issue/652-history-flake; fixed base origin/dev6ac345ace7. The assigned checkout remains detached at that head. No commits, pushes, merges, deployments or issue closure were performed. Only uncommitted scratch tests and their test include were added. Evidence and measurements are outside the repository at /home/kayg/codex-jobs/history-review; findings were appended to findings.md as the review progressed.Findings, ranked:
P1: real clients still confirm unjournaled state. Under SQLITE_FULL, capture the actual Rust failed server-edit broadcast and joining snapshot, then deliver those exact bytes to the unchanged TypeScript SyncClient. Both existing and joining peers report state
savedand call onConfirmed, despite receiving no Saved packet for the edit. The new failure broadcasts in room/merge.rs interact with SyncClient.remoteConfirmed, which treats remote state as confirmed when this device has no local pending edits. NoteSession can then store it as the safe replay base. Reproduce withcargo test -p calternal-notes -j4 independent_652_capture_failed_server_edit_protocol -- --nocapture, thenbun test scratch/editor-peer/peer.test.ts. Four client tests fail, including both actual-packet tests. Evidence and full reproduction.P1: recovery can reverse history order for the same note. A first 128 KiB typed edit fails the page quota; a second small edit fits an existing page and commits. After quota recovery, history authors are
["second", "first"], even though final text replay converges. queue_local submits later writes immediately; keeping receipts in deque order cannot prevent a later database commit overtaking a retry. Reproduce withcargo test -p calternal-notes -j4 independent_652_failed_first_typed_edit_must_precede_second -- --nocapture. This is a surviving typing-pipeline gap rather than a new typing regression. Evidence.P2: queued edits do not recover autonomously across SIGKILL. A failed API append is retained only in Room.inflight. After killing the recorded child and restarting on the same stores, its queued token is absent. Explicit same-key client resend restores it exactly once, including when resent twice. No acknowledged edit was lost in this test. ADR 0020's client-replay model works here; the stronger literal contract of server queue survival requires either a durable recovery source or an explicit client-replay condition. Reproduce with
cargo test -p calternal-notes -j4 independent_652_queued_api_survives_kill9 -- --nocapture. Evidence.P2: outage bookkeeping is not fully bounded. The typed edit deque caps at 1,024, and the next update is rejected before application. However, 10,000 valid save-check messages from one joined protocol client accumulate 10,000 PendingAck values with no response or limit. check_now pushes every request and release_acks scans the entire list each time, allowing unbounded memory and quadratic work. This existing gap remains in a prolonged outage. Reproduce with
cargo test -p calternal-notes -j4 independent_652_outage_queue_and_save_checks -- --nocapture. Local pending edits show Saving while connected and Not saved yet with an age after disconnect. Evidence.P2: the required loaded crash gate fails intermittently. The original
kill_nine_never_loses_or_doublesran 50 times serially with two background CPU workers: 49 passed, run 13 failed because final notes.save returned 503 instead of 200 at notes_crash.rs:213. Content and duplicate checks had passed before that assertion. No 500 assertion appeared in the captured logs, so the train's 500 was not reproduced. The original test discards this error body and suppresses server stderr, so the cause and attribution to this change remain unresolved. Exact failure.What passed:
Healthy per-edit save latency, measured from public Notes.edit append submission to its durable receipt:
Four pairs alternated execution order, with 200 warmups and 2,000 measured sequential edits per run, identical benchmark source and dev profile, and fresh builds in the assigned target directory. Pooled head p50 is 9.1% higher and p95 is 4.0% higher. The loaded shared host and varying paired results prevent attributing a production slowdown to this diff; the no-added-latency claim is not established by these results. Measurement details.
All heavy local commands used the required build-slot wrapper, cargo used -j4, and the original crash binary used --test-threads=1. Reproduction fixtures remain in this worktree's scratch tests. The executable review scripts are /home/kayg/codex-jobs/history-review/run-review.sh and correct-latency.sh; both must be run through the supplied build-slot wrapper.
The gate output below is verbatim from those harnesses. The initial eight LATENCY lines are invalid and discarded: SHA-256 checking caught shared-target cache reuse of one executable for both labels. The subsequent forced builds have distinct hashes; only VERIFIED_LATENCY and PER_EDIT_LATENCY are used above. Binary inspection also confirms the new history error marker is absent from the baseline and present in the head.
Starting fix round 2 on issue/652-history-fix2, base/head
389da8f1a6. origin/dev is already merged. I will port the independent reproductions, keep evidence outside the repository, and run the requested gates and VM comparison. No PR, merge, or deployment.The two P1 findings are confirmed in source: remoteConfirmed accepts live packets without a history receipt, and queue_local submits later room edits while a failed earlier receipt is still pending. I chose to keep immediate live packets and use the existing save-check protocol for every browser-observed update, including joining snapshots and tab updates. Only its later durable receipt can advance the safe replay base. This adds no disk wait to collaboration delivery; confirmation may wait for the existing check debounce plus disk. Holding broadcasts/snapshots would add disk latency to all collaboration, so I rejected that option.
History submissions are now serialized within a room; later edits stay in its bounded volatile queue until the preceding receipt succeeds. Save checks coalesce by connection, latest wins, including checks held for resync; incoming checks no longer scan/rebuild the waiting list. The retry queue is deliberately volatile under ADR 0020: after SIGKILL recovery requires a retained browser/client to replay unconfirmed CRDT state. Permanent regressions are being run, including production SyncClient driven by real Rust outage and restart packets.
The first outage regressions pass on the fix. The real SyncClient integration receives the actual Rust server-edit packets under SQLITE_FULL. It keeps both an existing peer and a joining peer in Saving with no confirmation callback, then replaces the volatile server room with committed state; the existing browser automatically sends sync step 2, the restarted room commits the retained state, and history replay contains the token once. The SIGKILL API reproduction is also retained with the corrected ADR 0020 expectation: zero queued tokens before client resend, exactly one after two identical keyed resends.
The 10,000-check test now asserts one pending entry, a two-second processing budget, latest receipt release, and recovery of the bounded edit queue. Checks held during resync also coalesce. I found that the referenced scratch/editor-peer directory is no longer present in the review checkout, so the permanent replacement is a small Bun bridge importing production SyncClient, driven by the Rust room regression rather than copied client code.
The 100-run crash diagnostic is in progress under two nice-19 CPU workers. No failure in the first 25 runs. All other local heavy checks are queued through the supplied slots; the release comparison is queued behind the perf VM lock. Its base is fixed origin/dev
6ac345ace7, matching the review comparison.The diagnostic crash run completed: 100/100 passed under two nice-19 CPU workers, with response-body diagnostics and retained stderr on failure. The earlier 503/500 has not reproduced so far; I will not guess its cause or silently retry an unexplained server error. A second 100-run gate against the final rebuilt binary is queued after the workspace checks.
Editor sync unit gate currently passes: 12 tests, including joining snapshots, idle peer updates, automatic replay after losing the server's live room, and NoteSession keeping its safe replay base behind unjournaled state. svelte-check reports 0 errors and 13 warnings in 8 files. The Chromium/WebKit editor e2e is running. I also extended the receipt rule to tab updates: an online tab forwards an offline tab's update before asking for a save receipt, so its receipt actually covers the observed document. A real browser regression checks server text, Saved, and reload for that case.
Validation update: fmt and clippy --workspace --all-targets -j4 -- -D warnings pass. Workspace tests (three serial runs), notes suite, and the final loaded crash loop are running/queued. The release comparison now holds the perf VM lock and is compiling.
The broader editor e2e observed a Chromium layout-shift failure and a CDP IME-start timeout. The scoped sync run against the rebuilt server passed 14 cases with one WebKit IME skip, but the Chromium IME-start command timed out again. The offline-tab receipt regression passes in both browsers. I am checking browser focus for the CDP command; no sync assertion failed in those runs.
Verbatim completed gate output:
The permanent regressions now reproduce the review failures on an isolated checkout of
389da8f. The Rust suite runs the production SyncClient through the Bun bridge; its existing-peer failure is from actual Rust packets under SQLITE_FULL. Verbatim baseline observations:The new editor unit tests also fail on
389da8ffor joining snapshots, live peer updates, and NoteSession's safe replay base. Each receives Saved where Saving is required:Those same editor tests pass on the fix (12/12). Client replay after losing volatile server state already worked on the baseline; the corrected SIGKILL contract test deliberately preserves that model rather than inventing a requirement for a persistent server queue.
The first workspace run exposed an old ack test expecting every intermediate receipt, which conflicts with the requested coalescing contract, plus a mistake in my added resync fixture: it attempted an update while the intentionally full edit queue still faced SQLITE_FULL. The ack test now verifies monotone receipts ending at the newest check and exact history text; the resync fixture lifts the quota before processing its resend. The independent first/second edit-order assertions are unchanged. The full gates are rerunning.
Validation found shared-target cache reuse, matching the review warning. The dedicated notes invocation ran an old baseline executable, despite printing the head source directory during compilation. I discarded that run. Binary inspection establishes the mismatch:
All three workspace runs used the head binary and passed. The dedicated notes suite and final crash gate are queued after a forced calternal-notes clean with CARGO_INCREMENTAL=0. The VM release benchmark also force-cleans the notes package between revisions and verifies distinct executable hashes before measuring.
The backend gates now pass fmt, clippy -D warnings, all three workspace runs, and the dedicated notes suite after a forced clean (330 passed, 1 ignored). The final 100 loaded crash runs are underway against the rebuilt head binary; the first diagnostic 100/100 had no HTTP 500 or 503, including streaming requests.
Validation blocker: the existing Chromium IME e2e times out inside Input.imeSetComposition. This also happens when the app is built with the unchanged
389da8fSyncClient, so the new receipt logic is not required to reproduce it. Programmatic focus, bringToFront, and a trusted click/key experiment did not resolve it; those unproven harness changes have been reverted. A bare contenteditable CDP probe responds. I am collecting a browser CPU profile before deciding whether there is a small, justified harness fix. The rebuilt-server sync e2e otherwise passed 14 cases, with the expected WebKit IME skip. The new offline-tab receipt case passes in both browsers. No sync assertion failed in those runs; the timeout happens when starting native composition.Release latency comparison complete on root@10.69.69.63. Each run held flock -o /root/perf-vm.lock. Fixed base: origin/dev
6ac345ace7. Four alternating base/head pairs, 200 warmups and 8,000 measured sequential public Notes.edit durable receipts per run, 32,000 samples per revision. Both revisions use the same benchmark source. The notes package was force-cleaned between release builds and executable hashes were checked before any run.Head is lower at all three pooled quantiles. Individual runs are noisy (base p50 ranges 1.542–3.087 ms); the first pair had a slower head tail, but subsequent pairs reverse that result. There is no repeatable added healthy-path cost in these runs, and these data do not justify claiming a precise speedup. The fix also removes one unnecessary diff copy on the synchronous API path by broadcasting live state before moving the diff into its retry queue.
Verbatim measurements and binary evidence:
Two validation corrections:
Verbatim failure:
Crash diagnostics now print the HTTP response body and keep the failed server's stderr file by path, without dumping it: startup stderr can include a temporary setup token. The final loaded gate is restarting with that privacy correction. The interrupted loop's recorded coordinator and its two recorded nice-19 workers exited cleanly after the active iteration finished; other jobs were not signaled.
The longer crash-test failure is understood. It was a stale snapshot assertion, not an HTTP failure: notes.save returned 200 and correctly added server-managed title frontmatter. The pre-save notes.get snapshot lacked that title. The disk and the current note still contained every confirmed token exactly once. The exact difference was:
Both crash tests now read the resulting note after notes.save before comparing exact file bytes, and recheck every confirmed token after saving as well as before. This preserves the loss/doubling assertions while allowing save's intended frontmatter updates. No retry has been added for unexplained HTTP errors. The original 503/500 remains unreproduced so far; the final 100-run gate will use the corrected assertions and retain failed stderr by path without printing secrets.
Persistent-disk release comparison: head is slower in all four alternating pairs, so the performance gate is not accepted. Each run measured 8,000 sequential edits after 200 warmups under the perf VM lock, with TMPDIR on ext4 /dev/sda1. The verified executable hashes are unchanged.
6ac345a7eca03bproduct sourceI have queued identical-binary sync-call traces (fsync, fdatasync, msync) under the same VM lock to determine whether the gap includes additional flushes. No speculative performance fix has been applied. The VM also reports substantial I/O pressure, but the repeated direction means I will not dismiss this comparison as noise. Earlier RAM-backed samples remain excluded from this conclusion.
Verbatim disk measurements:
The physical-disk slowdown was a benchmark fixture error I introduced, not an established product regression. The head source archive omitted the tracked .cargo/config.toml while the full baseline archive included it. That file sets LIBSQLITE3_FLAGS=-DHAVE_FDATASYNC=1. SQLite therefore used different flush syscalls in the two builds.
The trace proves the mismatch (same 8,000 measured edits plus warmups):
The prior physical-disk comparison is discarded for attribution to the change, just as the earlier RAM-backed samples were excluded from durable-disk conclusions. The tracked config is now present in both fixtures, with identical SHA-256 5023c7f76228053de8a1878e45dc25ea6eedef3c4324203be2c936e7e5bba5ba. I am force-cleaning SQLite and notes for both release builds, verifying that both use fdatasync with a short trace, then rerunning four alternating 8,000-edit pairs. The final fixture uses the VM's persistent XFS NVMe test volume (/mnt/z4-nvme/history-fix2), rather than RAM-backed /tmp or the busy root volume. Every run still holds the perf VM lock.
CI wiring is also included: the Rust image has no Bun, so the server build publishes the notes test executable alongside the server. The web job, which has Bun and installed dependencies, explicitly runs both Rust/real-SyncClient cases with its checkout's bridge path. A listing guard requires both cases before execution. This keeps Rust-only CI working while making those cross-language regressions mandatory in web CI; they are not silently skipped.
Matched-build performance finding, still unresolved: both release builds use the same tracked .cargo/config.toml (SHA256 5023c7f76228053de8a1878e45dc25ea6eedef3c4324203be2c936e7e5bba5ba) and benchmark source. Both short syscall checks recorded 275 fdatasync + 4 fsync calls. Measurements use persistent XFS /dev/sde on the perf VM, under its exclusive lock, 200 warmups + 8,000 measured edits each.
Four alternating base/head pairs, p50/p95/p99 milliseconds:
The pooled head median is worse, while its tails are better. This is not an all-clear on performance. Per-run drift is substantial; two reverse-order head/base pairs are queued after the final gates, under the same lock, to check order bias. No code change has been made on the assumption that this difference is noise. Final gates are now running on the isolated perf VM because the local build slots remained occupied by other trains.
Follow-up changes are now on
9e9f3f4(still unpublished).The matched-build physical-disk measurements did not establish an unchanged median. I removed avoidable healthy API work in room/merge.rs: after settling older writes, a successful API append now awaits History.append directly and advances the committed position. Only a failed append allocates a retained retry entry. The prior round-2 path created and popped an InFlight entry, cloned the author, and entered settle again for every successful API edit. Both paths retain the same diff for failed-write recovery. Typed edits still use queue_local/landed to enforce one submitted write per room.
A fresh release head build and four reverse-order head/base pairs (8,000 edits each) are queued under the perf VM lock after the final tests. Old performance numbers will remain labeled with their earlier implementation; they are not measurements of this optimization.
The first clean VM workspace run also exposed crash-test readiness parsers that assume their marker starts at column zero. With RUST_TEST_THREADS=1, libtest can put its progress prefix before child stdout on that same line. The readiness wait then fails despite the child reaching its crash point. Seven marker readers now recognize the marker after that progress prefix. No content, history, version, ordering, or crash-point assertions were relaxed. Subsequent workspace runs rebuild the changed fixtures and runtime code; an extra workspace pass plus final fmt/clippy are queued to require three passes on the final source.
Latest head is
9e9f3f42ad(not pushed yet). Focused serial runs verify every corrected child readiness parser. The original crash, text, history and version assertions remain in force. Verbatim focused gate output:The latest server browser rerun also finished. Verbatim sync unit result:
Verbatim sync e2e summary:
The new offline-tab receipt case passes in both Chromium and WebKit. The native Chromium CDP composition timeout persists; the full original-server plus original-client control previously failed 2/2 the same way. That gate exception remains explicit; no composition test has been weakened.
The local build slots became available. Final three workspace runs, notes and the two Rust/real SyncClient cases now run locally through the required build-slot wrapper, with a disk-backed private temporary directory. The obsolete VM workspace process tree was stopped using only its recorded own PIDs; it is not counted as a completed gate. The VM release measurements and loaded 100-run crash gate are queued under its lock behind another job.
Two final workspace attempts have exposed additional failures. These are recorded, not counted as passes.
First attempt, notes output verbatim:
The unchanged budget is one second, and the observed keystroke was 1.023556453 seconds while 600 notes were being renamed. All other notes cases passed (327 passed, 1 failed, 3 ignored). Host load was around 14; load is a hypothesis, not an established cause. The budget is unchanged.
Second attempt, storage migration output verbatim:
This is the offline-copy rollback phase, after copying split state back over single-root data. The focused case subsequently passed:
The third full attempt has passed storage startup and is running notes. No speculative metadata-store retry or assertion relaxation has been added. If the third pass completes, I will repeat full workspace gates serially to check these failures with less competition between test cases.
Final healthy API latency finding after restoring the direct successful commit path, head
9e9f3f42adagainst fixed base6ac345ace7.Release builds on root@10.69.69.63, exclusive flock -o /root/perf-vm.lock, persistent XFS /dev/sde, 200 warmups then 8,000 measured edits per run, four alternating head/base pairs. Each revision has 32,000 measured edits. Build configuration and benchmark source hashes match. Both verified builds use fdatasync; the short head verification again records 275 fdatasync and 4 setup fsync calls.
The final head's pooled percentiles are lower in this sample; there is no measured overall slowdown after removing the healthy retry-entry work. Individual pairs still vary substantially, so this is not a claim of a precise speedup. Final head release executable SHA256 is 34207eefa82dd2a1a73d7f422bf3ecb9cd6e306efa8f3fccbdf5b72e14f7892d; baseline executable is 42bd990329ec7446f4e378883267846eb9cc52e35460a423c61ef01da59fb418.
Verbatim per-run output:
The earlier
7eca03bmatched-build sample remains recorded above but measures the pre-optimization implementation. Earlier RAM-backed and mismatched SQLite-flag comparisons were discarded for the reasons already documented. No measurement files or tables are committed to the repository.Final loaded crash gate on
9e9f3f42ad: 100/100 passed on the perf VM under its exclusive lock. Two own nice-19 CPU workers ran throughout and consumed 1148.140 CPU-seconds. Every one of the 100 detailed test logs reports one passed test; no streaming HTTP error (including 500 or 503) was logged.The review's final-save 503 and train's 500 were not reproduced. Their original response bodies and stderr are unavailable, so these new runs cannot establish the source of those old statuses. No speculative retry was added to turn an unknown error into a pass. A future failing save now prints the response body and preserves that server's stderr path; the log contents are not printed because startup logs can include temporary setup tokens.
The separately reproduced old long-run assertion failure was a successful 200 save adding server-owned title frontmatter: the test had compared the file after save against text read before save. Both crash tests now check every acknowledged token before and after save and compare the file with notes.get after save. The exact title-only diff was recorded earlier on this issue.
Verbatim final loaded gate output:
All detailed logs are outside the repository. The private CPU workers were terminated by their recorded Popen handles after measurement.
Another reproducible finding from the serial workspace gate: a metadata refresh can block live sync behind uncommitted history. This explains the stalled-seed timeout; it is also a possible contributor to the earlier tag-rename timing failure, which remains to be checked with the full gates.
The existing stalled-seed crash test failed in its first phase. The backtrace reaches Client::join at fanout.rs:204, then Client::sync at clients.rs:243/345: the initial snapshot arrived, but the next sync response did not. A deterministic new regression settles the startup scan, stalls history, joins the room, then sends Cmd::RefreshMeta. Before the fix, that command waits for the seed's history receipt in Room::handle and blocks subsequent room messages.
Verbatim new regression failure before the fix:
Room::handle now treats RefreshMeta as a rebuildable description of live state, consistent with room loading and joining snapshots. It does not return a version or confirm a save. Versioned API reads and edits still settle history; save receipts still wait for their durable position.
The new regression proves that metadata refresh and sync continue while the seed is uncommitted, that Saved remains withheld, and that Saved arrives after releasing the stalled writer. Verbatim result:
The original stalled-seed crash test then passed 10/10 focused serial executions (each about 0.17 seconds). No timeout was increased and no durability assertion was relaxed.
New head:
da87ee43c6. The obsolete own serial gate process tree and its waiting duplicate notes command were stopped by recorded PIDs. Fresh fmt/clippy, three workspace runs, notes, real SyncClient and browser gates are running or queued; release timing and the loaded 100-run crash gate will be repeated on this runtime change. The earlier 100/100 and performance results remain labeled with9e9f3f4, not this new head.Validation environment choice on
da87ee43c6: the new metadata-refresh regression and the original stalled-seed case pass after the actor fix, but the first fresh physical-disk workspace run still failed the unchanged tag-rename timing budget at 1.027171135 seconds. Its other 328 notes tests passed, with 3 ignored cases. I am not attributing that timing failure to the metadata-refresh bug.The normal /tmp filesystem is RAM-backed. Earlier it was nearly full and a workspace process died with SIGBUS, so I moved test temporary files to persistent disk. It now has 22 GB free again (32% used). The general gates are returning to a private mode-0700 directory on that normal temporary filesystem, with serial test execution and a minimum 2 GB free-space check before each workspace run. All assertions and time budgets remain unchanged. This matches the normal temporary-file environment of these tests and reduces contention between their cases. The dedicated loaded crash gate uses persistent local disk; release benchmarking uses persistent NVMe on the perf VM.
The latest browser gate against
da87ee4completed:The same native CDP composition timeout was reproduced 2/2 with the original server and original client, as recorded above. Sync unit and svelte-check results will be quoted in the finishing comment. The new offline-tab receipt case again passes in both browsers.
Only the recorded own obsolete disk gate processes were stopped (1382055, 1393708, 1397842). The waiting duplicate VM notes gate was also cancelled using its verified own timeout/flock PIDs (1284073, 1284078), leaving the VM queue for the required final release measurement. No other jobs were signalled. The loaded 100-run gate on the final runtime will run locally through the build-slot wrapper, under two own nice-19 CPU workers, after the serial general gates. That also tests the original shared-host conditions more directly.
Pushed the new branch issue/652-history-fix2 at
da87ee43c6. No PR was created.Final local validation on that head: fmt and clippy -D warnings passed; all three complete serial workspace runs passed; the separate notes suite passed (329 passed, 3 ignored); the two real Rust/SyncClient cases passed explicitly; editor sync tests passed 12/12; svelte-check found 0 errors and 13 existing warnings. The two Bun-dependent Rust cases are ignored in the Rust-only suite and explicitly required by web CI; the third ignore is the existing index performance test.
The dedicated final loaded crash gate on the original shared host's persistent disk passed 100/100. Both own CPU workers ran at nice 19 and consumed 1101.550 CPU-seconds. Every detailed log reports one passed test; no streaming HTTP error was logged. The review's 503 and train's 500 remain unreproduced, so their original cause is unknown. Response bodies and the failed server's stderr path are now preserved for a recurrence. Startup stderr contents are kept private because they can include temporary setup tokens.
The browser gate remains 14 passed, 1 skipped, 1 failed: the native Chromium CDP IME call times out. The full original-server plus original-client control failed 2/2 the same way. The new offline-tab durability case passes in both Chromium and WebKit. Earlier physical-disk unit timing and offline-copy SQLite failures remain recorded above; no assertions or budgets were relaxed. General gates use their normal RAM-backed temporary filesystem, now with ample capacity and a free-space guard. Loaded crashes use persistent disk.
The remaining final-head performance gate is blocked on another job's exclusive perf VM lock. Its queued command will build the exact
da87ee4archive, verify the SQLite flush path, and run four alternating 8,000-edit pairs. Prior9e9f3f4measurements are labeled separately. I will post the actual final-head measurements when this lease becomes available.Verbatim final local gate runner output (the SQLITE_FULL messages are the intentional quota-injection cases):
Verbatim loaded 100-run output:
Verbatim editor sync output:
Verbatim browser summary:
Pushed
bcc2a3711eto issue/652-history-fix2. This final follow-up changes only packages/editor/src/note.ts, packages/editor/src/sync/client.ts and packages/editor/test/sync.test.ts.Two additional Saved windows are now permanent regressions:
Both new tests failed before the fix; the other 12 tests passed. Verbatim failure summary:
After the fix, all 14 sync cases and TypeScript checking pass:
The real Rust/SyncClient integration cases were rerun against this client and pass:
The browser rerun is still 14 passed, 1 skipped, 1 legacy Chromium IME timeout, reproduced with the original server/client as recorded above. Svelte-check remains 0 errors, 13 existing warnings.
The Rust tree, Cargo manifests, lockfile and build configuration are identical between
da87ee4and this head. Restoring the same crash-test build also gives byte-identical server and crash-test executables, so the three complete workspace passes, separate notes pass and final persistent-disk 100/100 run still cover the exact unchanged server. Verbatim executable hashes after the client-only commit:Those hashes equal the ones recorded before the client-only commit. The perf VM lease has now been acquired. Its archive marker reads
da87ee4because the client-only commit landed while that build was starting; its Rust inputs are identical to this head. The release Notes.edit benchmark does not use editor code. Both configuration and benchmark source hashes match the baseline, and the short trace again confirms 275 fdatasync + 4 fsync calls. Two alternating 8,000-edit head/base pairs have finished; two remain. Final p50/p95/p99 will follow when all pairs complete.A final failure-path cache finding is fixed in local head
b69da66b24; fresh gates are running before its push.A failed server/API edit was retained in the history retry queue without making the room dirty. A metadata refresh could then describe its unjournaled live text using the old file's clean stamp. After a crash, the startup scan could reuse that description because the old file still matched the stamp. The missing dirty flag also meant a recovered history write did not schedule the deferred file write.
The new permanent regression forces SQLITE_FULL after saving the original file, applies a retained edit, refreshes the list twice (including the cached-row reuse path), and requires a live stamp. It then restores history capacity and verifies that save writes the exact recovered text once. Verbatim before-fix result:
Retain_local now marks a newly dirty room only when the initial submission fails. Existing dirty state and its timezone are preserved; a newly dirty server retry uses UTC. Successful API commits still use the direct path, and successful queued submissions do not enter this branch. No durable queue was added.
Verbatim after-fix result:
The preceding server revision's completed matched-build performance sample was base p50/p95/p99 7.040826/14.861332/30.341284 ms, head 6.618957/14.738631/27.917773 ms (32,000 edits per revision). That sample predates this failure-only correction and remains labeled separately. A new exact-head release build and four alternating 8,000-edit pairs are queued under the perf VM lock.
Fresh fmt/clippy and the first complete workspace pass have succeeded on
b69da66. Two more workspace runs, the notes suite, real SyncClient cases, a new loaded 100-run gate, and browser checks follow. The browser gate will use an immutable copy of the exact server built for the loaded crash gate, so later builds cannot swap its executable underneath it. Client code remains the already-testedbcc2a37version (14 sync tests passed).Fix round 2 finished. Pushed only issue/652-history-fix2, head
b69da66b24. Remote SHA verified and worktree clean. No PR, merge, deployment, or issue closure.The implementation keeps immediate live collaboration and makes Saved an explicit history receipt. Every incoming peer update, joining snapshot, cached document, and persistence update requires confirmation before it can become the replay base. Holding broadcasts would add the history write latency to every collaborator; the receipt design preserves live update latency and delays only Saved. The existing confirmation debounce is about 150 ms. Changes from offline tabs are forwarded before checking durability. Permanent tests use the real Rust packets and the production SyncClient, including reconnect/replay after loss of the volatile server queue. Those two Bun-dependent Rust tests are explicitly run by the web gate and CI rather than silently relying on Rust-only test jobs.
The room pipeline submits only the oldest applied edit. Failed writes remain at the front, and newer edits wait for its receipt. Pending checks use one entry per connection, latest wins; resync holds one optional check. There is no per-check queue rebuild. The permanent outage regression sends 10,000 checks, asserts exactly one pending entry and a two-second work bound, then another 10,000 during resync and asserts one held value. It passes in all final suites. Retained failed edits also keep file/list metadata dirty until the file mirror catches up. Metadata refresh no longer blocks live sync behind a stalled initial history write; its regression verifies no Saved receipt before release.
The contract remains ADR 0020: pending server work is volatile. SIGKILL can discard it; the browser retains its last confirmed base plus unsaved edits and replays them after reconnect. No durable server queue was added. Product comments and regressions state this contract. The original review reproductions were ported as permanent regressions and verified against the old revision as recorded above. The review worktree was only read.
Crash result: final head passed 100/100 under two nice-19 CPU workers. Their measured CPU consumption was 1145.680 seconds. All 100 detail logs contain a passing result; none contains a 500/503 response or panic/failure marker. The old reported 503/500 could not be assigned a cause because its body and stderr were discarded; I have not claimed it was a startup response or added speculative retries. Diagnostics now include response bodies and retain failed server stderr by path, without printing setup secrets. A separate reproduced long-run assertion failure was a successful save adding title frontmatter; the test now compares the file to the post-save document, with edit-token assertions before and after. No history or edit-loss assertion was weakened.
Final release performance on root@10.69.69.63 held flock -o /root/perf-vm.lock for the complete build and run. Base is merged dev
6ac345ace7; head isb69da66b24. Both use the same benchmark and .cargo/config.toml on persistent XFS /mnt/z4-nvme/history-fix2. Four alternating head/base pairs, 200 warmups then 8,000 measured edits per invocation, give 32,000 samples per revision. The head short syscall check observed 275 fdatasync and 4 fsync calls; the matching base control was verified earlier. Configuration SHA 5023c7f76228053de8a1878e45dc25ea6eedef3c4324203be2c936e7e5bba5ba; benchmark SHA a7f58a11f1bdcdb9881af2bf499d679f1c93f39a3ae7d583571e96e1021405c8. Head executable SHA 760d293cf6d14fa7888cde46da6fc42f0e11ff9416b43ee5b1ae5c637448d9eb; base executable SHA 42bd990329ec7446f4e378883267846eb9cc52e35460a423c61ef01da59fb418.Pooled sorted-sample percentiles, milliseconds:
The healthy API path avoids the temporary queue and extra settle on successful writes. These noisy measurements show no overall regression; they do not establish a precise speedup. Pair three has a slightly higher head median and tail, and pair four has a higher head tail; all pair outputs are included below. Earlier mismatched SQLite flush settings and RAM-backed measurements were discarded as documented above.
Gate status: fmt, clippy -D warnings, workspace tests three times, notes suite, explicit real SyncClient integrations, 100 loaded crash runs, 14 editor sync unit tests, TypeScript, and svelte-check passed. Svelte-check has 13 warnings in 8 files and zero errors. Browser e2e is not fully green: 14 passed, one existing WebKit IME skip, one Chromium IME timeout. The full original server/client control reproduced the same native IME timeout twice. The new offline-tab durability e2e passes in both engines. No browser assertion was skipped or relaxed to hide the failure. This remaining gate exception is explicitly unresolved; do not treat this as an all-green merge recommendation.
Verbatim final core gate output (expected SQLITE_FULL messages belong to injected outage tests):
end-core.log
end-end-crash100.log
end-editor-check.log
end-editor-sync.log
end-rust-syncclient.log
Svelte-check final output, verbatim:
Browser e2e output, verbatim:
Final alternating release run output, verbatim:
Detailed logs, traces, raw sample JSON, and discarded-run evidence remain outside the repository under /home/kayg/codex-jobs/history-fix2; final raw samples are in end-perf. No evidence artifacts were committed.
Second independent review of
b69da66(issue/652-history-fix2)Verdict: do not merge.
The safety fix itself holds up. I checked it end to end with the real server binary and the real browser sync client:
It still can't merge. Its own new CI test fails every time, it makes "Saved" fall seconds behind on slow disks when people type steadily, and it introduces two browser regressions.
Base for all comparisons:
6ac345a, the merge base. origin/dev (3541649) doesn't touch these crates, andb69da66merges onto it cleanly. Full evidence: /home/kayg/codex-jobs/history-review2/findings.md. Scratch tests are uncommitted in /home/kayg/Developer/calternal-wt-histrev2.Findings
P1: the new "real SyncClient" CI tests fail every time.
CI runs
independent_652_real_syncclient_*on bun 1.4.2, and both fail after 30 s:Error("EOF while parsing a string", line: 1, column: 65536).The bridge (
packages/editor/integration/history-peer.ts) prints a JSON line bigger than 64 KiB (it holds the 128 KiB note) withconsole.loginto a pipe. Bun 1.4.2 writes the first 65,536 bytes and then stalls. Fed a 1,000-character insert, the bridge returns a complete 5 KB line; at 60,000 or 70,000 characters it returns 65,536 bytes and never finishes the line.Merging this turns the web CI job red. With a scratch copy of the bridge that writes with a blocking
fs.writeSync, both tests pass. So the logic is fine and the bridge is the problem.P1 (performance): history writes are now one transaction per edit, per note, so "Saved" falls behind on slow disks.
queue_localsubmits a note's next write only after the previous one commits, so every typed change pays its own fsync. Before, a burst of typing shared one transaction.On top of that, the server keeps only each connection's latest save check, and the client drops older check ids. Once the backlog is longer than the 150 ms check interval, no check is answered until typing stops. If the backlog reaches 1024 edits, typing waits on the disk and everyone's live sync in that note slows down.
Real spinning disk on the perf VM, release build, one note, 10 s of typing:
The emulated slow disk (
crates/notes/scratch/review2_both.rs, same source on base and head) shows the same: at 50 ms per transaction and 30 typed updates/s for 12 s, base answered 71/73 checks with a worst wait of 0.21 s; head answered 1/73 with a worst wait of 18 s.Suggested fix: when the front write commits, submit all of that note's deferred diffs as one job in one transaction (all or nothing). Also keep more than one pending check per connection, so confirmation still makes progress during long typing.
P2: every note opened offline shows "Not saved yet", and just opening a note marks it pending on disk.
carried = opts.pendingSince ?? Date.now()makes a note with no editsnot-savedfrom the start. After 2 minutes offline the editor shows "These changes are only on this device so far."The same value is saved to IndexedDB as
pendingSince, which feeds the sign-out "unsent edits" check. Online, every freshly opened note stays unconfirmed for at least 150 ms plus a round trip.Reproduction:
packages/editor/review2/offline-open.test.tsgives"state":"not-saved","words":"Not saved yet · 3 min"on head and"saved"on base.P2: a Playwright test that is stable on base now fails often on head.
signout.spec.ts:221"online: disk, other tabs, history…" passes 16/16 on base and 10/16 on head, failing on chromium-1440, webkit-1440 and webkit-390. The failure is at line 247:expect(signIn(second)).toBeVisible(), meaning the second tab keeps showing the note after the first tab signs out. That test signs out right after opening the second tab, which is exactly when head now considers the note unconfirmed (see the P2 above). I did not trace it further.P3 (also on base): a note stops responding for over a minute while SQLite is busy.
During an SQLITE_BUSY outage, a joining peer took 74–115 s on head and 74 s on base. Retries wait on the 5 s busy timeout inside the note's single worker task, so joins queue behind them.
P3 (from reading the code; not reproduced):
Contract checks
Nobody sees "Saved" early: holds.
packages/editor/review2/e2e.ts), with another process holding the history.db write lock. During the outage the existing peer stayedsavingwith 0 new confirmations, and the joining peer stayedsavingwith 0.saved, 1 confirmation; joinersaved, 1 confirmation.peer.test.ts, fed the actual Rust SQLITE_FULL packets re-captured on head, now passes 4/4 ("state":"saving","confirmations":0).History order: holds.
["first", "second"].kill -9 replay: holds.
Save checks during an outage: bounded and linear. 10,000 checks from 4 peers took 10.2 ms and left 4 pending; 100,000 took 126.5 ms (1.27 µs each) and left 4 pending. After recovery each peer gets exactly one answer.
Crash test under load: 50/50 passed.
kill_nine_never_loses_or_doublesran 50 times with two nice-19 CPU workers. No non-200 response appeared: no stream append, no notes.save.Single-edit latency, perf VM, release build: 4 alternating rounds × 1,000 edits = 4,000 per revision. All times in ms.
Head's whole difference comes from its first two rounds; rounds 3–4 match base to within 1%, so I read it as noise.
On the spinning disk (600 edits each), typed edit → Saved was p50 12.4, p95 27.2, p99 45.4 on base and p50 12.4, p95 30.0, p99 47.6 on head.
Peers still get live updates immediately; broadcasts are not held until commit. The regression is under sustained typing (the P1 above), not for a single edit.
No leaks: holds. While history was locked,
notes.append,notes.getandnotes.saveeach returned 500 with only the generic catalogue message ("Something went wrong on our side. Trying again might help."). A regex for sqlite, database, Busy, history.db, /home/, INSERT, UPDATE and SELECT found nothing.New problems:
Gates (verbatim)
cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceThe ignored real-SyncClient tests, as CI runs them (bun 1.4.2):
The same tests with the scratch writeSync bridge:
Editor sync tests (
bunx vitest run test/sync.test.ts test/local-copy.test.ts)Playwright: editor, signout, pwa-update and switching specs on chromium-1440, chromium-390, webkit-1440 and webkit-390,
--workers=1The author's reported Chromium IME timeout does not reproduce on this host. On origin/dev
3541649the IME test passes 6/6 (--repeat-each 3on chromium-1440 and chromium-390). It also passes on base6ac345aand on head.Round 3 fix started (issue/652-history-fix3)
Branched from
b69da66(fix2) with origin/dev merged in. Working through comment 62243:The reviewer's scratch reproductions will be ported as permanent tests. Measurements on the perf VM (base vs head, alternating, flock'd) will follow, plus all gates verbatim.
Round 3: findings and fixes so far (
709c30f,80ade7eon issue/652-history-fix3)P1 bridge. Confirmed:
console.logof a >64 KiB line into a pipe stalls in Bun 1.4.2.history-peer.tsnow writes each reply withwriteSyncin a loop until every byte is out (EAGAIN-safe), and no longer waits a fixed 5 ms (it yields to the event loop instead). The twoindependent_652_real_syncclient_*tests are no longer#[ignore]: they run wherever Bun is installed and skip with a message where it isn't (the Rust CI image). In CI's web jobCALTERNAL_SYNC_BRIDGEis set, which makes Bun required, so they fail rather than skip; the step no longer passes--ignored. Locally (bun 1.4.2) both pass in about 1 s.P1 slow disk. Cause confirmed: one transaction per edit per note, plus only the latest check kept per connection. Fix:
history/batch.rs): when a batch fails, every later batch of that note fails too without writing (so other notes' writes in the same transaction aren't rolled back), and the room resends everything not yet durable as one batch in a new generation. Nothing is acknowledged before its commit.P2 offline open. The client no longer assumes unconfirmed state on open. The local copy (IndexedDB) keeps an "unconfirmed local edit" marker written in the same transaction as the first unconfirmed local edit, and cleared once every own edit has a receipt. Changes from the server or another tab never set it. So only real local edits count, and the crash gap the round-2 default guarded against is closed.
P2 signout.spec.ts:221. Root cause is the P2 above. Opening the note in the second tab persisted
pendingSinceto IndexedDB. Sign-out (unsentChangesin wipe.ts) waits up to 3 s for pending notes to clear, then shows the "Sign out?" confirmation. The test checks that the dialog count is 0 straight after the click (which passes before the dialog appears), then times out waiting for the second tab's sign-in screen, because the first tab is stuck on the confirmation. With the fix, a quick run passes 12/12 across the four projects. The 30× runs come with the gates.P3s.
changedevent goes out once it is durable, whether or not the caller retries, and only once (a_retried_api_edit_sends_its_changed_event).confirmed=false, no new confirmations, and no Saved packet during the outage). A peer that types during the outage stays "saving".rewrite_allstill awaits busy_timeout plus backoff inside the room actor.Ported as permanent tests (
room/save/group_commit.rs): group commit in one transaction with one cumulative answer, a failed write never overtaken, mixed paths keeping order through a retry, two notes keeping their own order, a peer joining mid-retry, Saved after recovery with no new activity, and checks during an outage staying bounded. The slow-disk method is inroom/save/slow_disk.rs(ignored, a measurement), and per-edit latency and steady-typing lag are inexamples/saved_lag.rs. The offline-open and peer reproductions became vitest cases inpackages/editor/test/sync.test.ts.Round 3 done: issue/652-history-fix3 @
a21bc054d0The commits on top of fix2 + origin/dev:
709c30f(fix),80ade7e(saved_lagexample),a21bc05(the perf live client and fanout bench treat Saved as cumulative; the storm bench would otherwise have waited for coalesced ids). What changed and why is in comment 62310. No PR, merge or deploy.Measurements (perf VM 10.69.69.63, release, every run under
flock -o /root/perf-vm.lock, alternating base/head)Base =
6ac345a(the merge base the review used) with the same measurement source added. Binary hashes: basesaved_laged04f3ee…, head d06fc1e5…; test binaries d0f4f2f2… and 295e3315….One edit at a time, SSD (sda): 4 rounds × 1,000 edits = 4,000 per revision, in ms
Per-round p50 of saved/api: base 3.95/4.25, 3.93/4.29, 4.53/5.12, 3.99/4.28; head 3.89/4.27, 3.90/4.26, 3.99/4.33, 4.03/4.49. The VM's SSD was slower today than in the review (base 4.0 ms against 2.6 ms then), so compare base and head from the same session only.
Steady typing at 60 edits/s on the spinning disk (sdb, /mnt/b/hdd-ext4): 4 rounds × 10 s per revision. Each value is the time an edit waits for a covering Saved (checks every 150 ms, so about 75 ms of the wait is the check interval itself).
The mean p95 is 181.4 ms on base and 179.3 ms on head. The worst case is 251 ms on base and 309 ms on head, under the 0.5 s target. Saved arrived 5–23 ms after typing stopped on base and 5–6 ms on head. Round 2 had answered 10/64, with worst waits of 5.5–8.3 s.
Emulated 50 ms disk at 30 edits/s (the review's
History::stallmethod,room/save/slow_disk.rs): 2 rounds × 12 sThe 4 s matrix (base, then head): at 5 ms and 30/s the worst wait was 201.9 / 169.2 ms; at 20 ms and 60/s, 184.4 / 185.2 ms; at 50 ms and 30/s, 201.9 / 201.8 ms. Round 2 took 18 s.
Gates (verbatim; local host, heavy commands through the build slots)
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked, 3 runsTwo of the ignored tests are the new slow-disk measurements. The real-SyncClient tests now run in this suite.
notes_crash kill_nine_never_loses_or_doubles, 50 serial runs with two nice-19 CPU workers (only their own PIDs killed afterwards)The real-SyncClient tests as the CI web step runs them (bun 1.4.2)
Editor sync tests (
bunx vitest run test/sync.test.ts test/local-copy.test.ts test/traps.test.ts, bun 1.4.2)All editor unit tests (
bun run check && bun run testin packages/editor)svelte-check (
bun run --cwd apps/web check)(The warnings are existing unused-CSS and state notes in files this change doesn't touch.)
Playwright: the editor, signout, pwa-update and switching specs on chromium-1440, chromium-390, webkit-1440 and webkit-390,
--workers=1signout.spec.ts:221 --repeat-each 30on chromium-1440 and webkit-1440That is 30/30 on Chromium and 30/30 on WebKit. Round 2 passed 10/16.
Changed behaviour to review
confirmed=falseand no new confirmations in the real-SyncClient tests). A peer that types during the outage stays "saving". The review'se2e.tsreportedC_state_during=savingfor a joiner that didn't type; that would now readsavedby design.Follow-ups (not fixed here)
rewrite_allstill awaits busy_timeout plus backoff inside the room actor, so joins and sync wait behind it. The fix is to schedule retries from the room loop instead of awaiting them inline, butsettle()callers (gets, API edits, saves) rely on the awaited retry, so it needs its own change.Verdict: do not merge (1 P1; everything else verified or P3). Full third review below.
Third independent review of issue 652
Reviewed head:
a21bc05(issue/652-history-fix3). Base:3541649(merge base with origin/dev). Round-2 head:b69da66.Worktrees: /home/kayg/Developer/calternal-wt-histrev3 (head), -histrev3-base (base), -histrev3-r2 (
b69da66). Scratch stays uncommitted (packages/editor/review3/, harness copies in /home/kayg/codex-jobs/history-review3/harness/).Findings are appended as evidence arrives.
P1 (raised from P2 after a real-server reproduction): a tab marks a sibling tab's edit as confirmed (and moves its safe replay base) although the server never received it
Round 3 stopped tabs forwarding each other's updates unless the sending tab was offline when it typed (
off: !transport.connected). But a tab still counts every sibling-tab edit as its own observed change (ownChange), and the server answers a check for everything the room has applied when the check arrives, not for what this tab sent. If the typing tab's socket still says "connected" but its frames are stuck, the other tab's check is answered without covering the edit. That tab then shows Saved,isConfirmedbecomes true andonConfirmedfires, so NoteSession stores the text including the edit as the safe replay base. Ways a socket can be connected but stuck include a large upload queued ahead of the frame, a half-open TCP connection before the ping timeout, or a socket that closes with the frame still unsent.Reproduction: packages/editor/review3/client.test.ts, test
R3-TAB(in-memory room; tab B's transport keepsconnected=truebut holds its frames). Run:bunx vitest run --config review3/vitest.config.ts -t R3-TAB.This breaks contract 1, "nothing reaches a client's safe replay base before a durable receipt". The receipt A holds is for a check that did not cover the edit. The data usually survives: B keeps its frames, B's local copy carries the dirty marker, and A's next reconnect sends the update in step 2. The safe base is still wrong, though. Suppose the lineage changes next (a seed lost in a crash). Then
recover()diffs from a base that already contains B's edit, so the edit is not replayed. Possible fixes:Real-server reproduction (why this is P1). Script: packages/editor/review3/e2e-tab.ts. It runs the real
calternal serveplus two production SyncClients on the note's BroadcastChannel, each with its own LiveSocket. Tab B pastes 1.2 MB, which is over the server's 1 MiBMAX_MESSAGE, so the server drops B's frame. Tab A gets the paste through BroadcastChannel; on head it does not forward it, and the next check is answered:On head, tab A says "Saved" and fires
onConfirmed, so NoteSession stores a replay base containing the paste, for an edit of this device that the server rejected and will never commit. The same tab on round 2 correctly stays "not-saved". A paste over 1 MiB that cannot sync at all is an existing limit. The new problem is the second tab claiming it was saved.Verified: real server and real SyncClient under a forced history outage (contracts 1 and 3)
Harness: packages/editor/review3/e2e.ts, round 2's e2e.ts extended. It runs the real
calternal serve(head debug build) with the production LiveSocket and SyncClient, using Bun as the browser. Another process holds history.db's write lock (BEGIN IMMEDIATE, so the server gets SQLITE_BUSY). The sequence:<E2E-ONE>plus 20 queued edits<Q0>…<Q19>, 30 ms apart.<E2E-TWO>.The harness counts tokens in the note and in history.db
updatesrows.No browser's safe replay base (
onConfirmed/isConfirmed) moved during the outage. Every queued edit committed exactly once after kill -9 and browser replay. B and C show "Saved" while they hold A's uncommitted edit; that is the author's new rule, judged next.Judgement on "a peer only needs Saved for its own edits": safe enough, with one narrow loss path (P3)
isLocalexcludes the server's origin).stored.basemoves only whenisConfirmedis true, which needs a receipt covering everything observed (confirmed >= seen, andbaseUnknowncleared). Verified in the e2e above, where B and C had 0 onConfirmed calls and isConfirmed was false.recover()diffs from the old base, which does not contain the held change, so the peer replays it. packages/editor/review3/client.test.tsR3-HELD: the typist dies, the room re-seeds from committed text, and the server ends with"line one\ntypist line\n".pendingSinceis null, so sign-out (wipe.tspendingNotes()andstoredPendingIds()) does not warn. If the typist's device never comes back with its own copy and the server crashed before commit, a peer that signs out mid-outage destroys the last copy. This needs three independent failures and is a reasonable design trade-off. Consider counting "holds unconfirmed observed state" (!isConfirmed) in the sign-out check only, not in the visible status.P3: rollback hazard. Pre-652 clients cannot open a local copy that head marked unconfirmed
Head stores the marker as a number under the string key
dirtyin the same object store as the updates. Base and r2LocalCopy.all()use an unboundedgetAll(), so they feed that number toY.applyUpdate, which throws. packages/editor/review3/rollback.test.ts, run in theb69da66worktree (local-copy.ts is identical to base):If the release is rolled back, every note that holds unconfirmed local edits (exactly the notes whose local copy matters) fails to open its local copy in the old client. A base tab still open during an update aborts its compaction transaction instead, which loses nothing. Possible fixes: keep the marker in a separate object store (this needs a DB version bump, which old clients refuse cleanly), or put it in the meta store.
Verified: per-note lanes (contract 2)
Scratch test file: crates/notes/scratch/review3_lane.rs (uncommitted, included from review.rs). Run:
cargo test -p calternal-notes --lib review3_ -- --nocapture --test-threads=1.Caveat (P3, design): a real (non-doomed) statement failure still rolls back the whole group transaction. That includes other notes' writes, which then resend through their own lanes, so nothing is reordered or lost; the test above shows they recover. Doomed writes no longer cause such rollbacks. A SAVEPOINT per job would isolate even real failures. On this tmpfs host I measured no starvation of another note while one note's lane kept failing.
A crash between a lane failure and the resend is covered by the e2e above: the kill came while every write was failing, and after restart and replay each edit appears exactly once.
Verified: "changed" for a retried API edit (contract 7)
The deduplicated retry path in edit.rs runs only after the actor's
settle()succeeds, becauseCmd::Editis a "reads" command (actor.rs), so it never answers success before the edit is durable.unannouncedis emitted once: byannounce()after the room's loop lands everything, or by the retry, whichever comes first, and then it is emptied. The author'sa_retried_api_edit_sends_its_changed_eventpasses, and I agree with what it asserts. Minor: under nonstop typing,announce()waits until nothing is in flight, so the event can lag while someone types.Verified: offline open (contract 6)
R3-OFFLINE {"state":"saved","words":"Saved","persisted":[null]}. The round-2 P2 is fixed. The marker is written in the same IndexedDB transaction as the first local edit (put([update], mark)). Write-ahead-list entries carryl:1, so a crash before IndexedDB commits still restores the marker on the next open.markCleanruns only whenpendingSincebecomes null, which can happen only once every own edit (a superset of LocalCopy-local edits) is confirmed. Delete-then-put ordering holds because both are readwrite transactions on one store.kill -9 (contract 3 gate)
kill_nine_never_loses_or_doublesran 50 times serially with two nice-19 CPU workers: pass=50 fail=0, with 0 non-200 stream-append responses logged. Typical run: "30 kills, 261–267 confirmed appends, 29 in-flight appends retried".Verified: bounded save checks (contract 5)
Scratch test
review3_checks_bounded_per_connection: the disk is stalled, and 1,000 edits are each followed by 10 checks on each of 2 connections, 20,000 checks in total. Result:max_pending_two_conns=32 pending_after=0 last_answer_a=10000. That is at most 16 per connection, and one cumulative answer per connection at the end (answers_b=2).Verified: peer check debounce, without starving the peer's own Saved (contract 8)
packages/editor/review3/debounce.test.ts, with production delays (150 ms own, 300 ms quiet / 2 s max base). Typist A sends 20 remote updates per second for 5 s. Peer B types once in the middle:
R3-DEBOUNCE {"peer_checks":3,"typist_checks":33,"peer_own_saved_ms":172,...}. The peer sent 3 checks in 5 s, and its own edit was Saved in 172 ms. Tab traffic is counted in the P1 above, which is the cost of not forwarding.Performance (contract 4): round 2's slow-disk P1 is fixed, and there is no regression
Perf VM root@10.69.69.63 under
flock -o /root/perf-vm.lock, release builds in /root/review652-3. Base3541649and heada21bc05run identical harness sources: examples/review3_lag.rs (the author's saved_lag.rs, reviewed; it times Saved from the forwarder task's receive time) and scratch/review3_slow.rs (round 2's History::stall method). The order alternates base→head, then head→base. Binary hashes are in results/hashes.txt.Single edit, 4 rounds × 1,000 = 4,000 edits per revision (ms):
The HDD API tail on head is worse only in its first two rounds, and matches base in rounds 3 and 4: the same pattern round 2 saw, which I read as disk noise rather than a regression. Single-edit Saved is unchanged.
Steady typing at 60 edits/s on the HDD, 10 s, 6 rounds each. Per-edit wait for a covering Saved (ms):
This matches the author's claim (p95 about 179 vs 181). Their worst case of 309 vs 251 is within the spread I see in both builds: here base had the worst single round. Round 2 measured 5–8 s of lag for head at this rate.
Emulated 50 ms disk at 30/s, 12 s, 4 rounds each. Every round on both builds was:
checks_covered_while_typing=71/72 edit_wait_ms p50=101.6 p95=200.7 max≈202 final_saved_after_stop_ms≈30. In the matrix, 5 ms at 30/s, 20 ms at 60/s and 50 ms at 30/s are identical between base and head to within 2 ms. On round-2 head this was 1/73 checks answered with an 18 s worst wait.P3: signout.spec.ts:221 still flakes on head, rarely (round 2 measured 10/16)
The same specs ran on the same host with
--workers=1:Head has 1 real failure in 120 runs of :221, against 0 in 60 on base. That is much better than round 2 but not shown to be gone. The second-tab EditorView re-entrancy error appears only in head's failing run. Worth a look before calling it fixed, but it does not block on its own.
P3 (carried over, still present): joining during a SQLITE_BUSY outage takes minutes
In the e2e runs above, C needed 149 s ("all") and 88 s ("typist-gone") to finish joining while the lock was held; round 2 measured 74–115 s.
rewrite_allstill awaits up to 3 × (5 s busy_timeout + backoff) inside the room actor. This is not new, and the run-to-run spread is large.Gates (head
a21bc05, this host, cargo -j4, Playwright --workers=1)Verdict: do not merge (one P1)
Round 3 fixes every round-2 blocker. The slow-disk Saved lag now matches base on a real HDD and on the emulated 50 ms disk. The real-SyncClient CI tests pass. An offline open is Saved. The signout flake is down to 1/120. Lanes keep per-note order through failures, kill -9 commits each queued edit once, checks are bounded, "changed" goes out once, and all gates are green.
The blocker is the new no-forwarding rule between tabs. A tab counts a sibling tab's edit as its own and confirms it with a receipt that never covered it. Reproduced end to end with the real server: a >1 MiB paste in tab B leaves tab A showing "Saved", with
onConfirmedfired and the paste in its safe replay base, while the server never received it. Round 2's client did not do this. A minimal fix is to forward sibling-tab updates again, which costs only bytes, or to confirm a sibling's edit only from that sibling's own receipt.Round 4 started (issue/652-history-fix4, from
a21bc05+ origin/dev)Working through review 3 (comment 62424):
Round 4 done: issue/652-history-fix4 @
6287c7a870Branched from
a21bc05with origin/dev merged in. Commits:94131ad(tab confirmation, paste pieces, rollback-safe marker, held-change sign-out warning),366b773(signing-out page stops touching note copies),6287c7a(keeps the test at :221). No PR, merge or deploy.What changed
isConfirmedfalse, replay base unchanged). In normal operation tabs still don't re-send each other's updates. Ported asa tab never confirms a sibling tab's edit the server has not got (review 3, R3-TAB)(stuck socket): the receiving tab stays unconfirmed, then sends the edit itself, andonConfirmedfires only once the server has it.+<room>frames for the leading pieces, then the last piece for<room>. The server joins the pieces up to a 64 MiB cap (MAX_ROOM_MESSAGE, same constant on both sides).{"type":"too_large"}, and the whole message (every remaining piece) is skipped, never half-applied.apps/web/e2e/big-paste.spec.tspastes 1.2 MB and 10 MB and checks that the paster's tab shows Saved,notes.getreturns the full text (it answers only after history is durable), the version list has a newer version, and both the other tab and a collaborator in another browser context have exactly the server's text. It passes 8/8 on all four projects.dirty@<ms>. Older clients read every value as an update, so to them it is a no-op, and their compaction just drops it.test/local-copy-rollback.test.tswrites a marked copy with the current code, then opens and compacts it (520 edits) with a frozen copy of the round-2LocalCopy(test/fixtures/local-copy-r2.ts, fromb69da66, same as base), and reopens the result with the current code./healthzwithin 5 s while cargo tests loaded the host. The poll now waits up to 30 s.calternal-note-day-<date>still held data. The page that signs out, or that hears it from another tab or the server, is only replaced by its reload some time later, and until then it could still open or write note copies while the next page deletes them. The same window would explain the second-tabEditorView.updateerror the review saw.stopNotes()(packages/editor) closes every open note and refuses new ones; the wipe'sleave()and the remotesessionEnded()call it before reloading. Closing a local copy now writes not-yet-committed IndexedDB writes to the write-ahead list first.heldSince). The status stays about own edits. Sign-out'spendingNotes()counts open notes holding such changes.heldSinceis written to the meta store only if a receipt is still missing after 2 s, so opening a note and leaving at once never makes sign-out warn.storedPendingIds()in wipe.ts reads it alongsidependingSince. Test:a collaborator's change held unconfirmed makes signing out warn.rewrite_allwaits for busy_timeout plus backoff inside the room task. Still open as a separate issue.Steady typing on the perf VM HDD, 60 edits/s, 4 alternating rounds × 10 s (flock'd, release)
The notes crate is unchanged in round 4, so head's
saved_lagbinary hash is identical to round 3's (d06fc1e5…); base is ed04f3ee….Median p95 is 185 ms on base and 183 ms on head. Head's worst wait is 287 ms. Base's round 2 hit a 1.4–1.7 s disk stall that head's rounds did not.
Gates (verbatim)
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked, 3 runs (at94131ad; later commits change only TypeScript and a spec)kill_nine_never_loses_or_doubles×50 with two nice-19 CPU workersThe real-SyncClient tests as the CI web step runs them (bun 1.4.2)
Editor unit tests (
bun run check && bun run testin packages/editor)svelte-check
Playwright: editor, signout, pwa-update and switching, plus the new big-paste spec, on chromium-1440, chromium-390, webkit-1440 and webkit-390,
--workers=1signout.spec.ts:221 --repeat-each 60on webkit-390 and chromium-390Review 4 of
6287c7a: do not merge (one P0)Full findings with reproductions: /home/kayg/codex-jobs/history-review4/findings.md. Scratch tests are uncommitted in /home/kayg/Developer/calternal-wt-histrev4 (packages/editor/review4/, apps/web/e2e/review4-signout.spec.ts).
P0: an over-limit edit shows "Saved" (and moves the safe replay base) about 150 ms after it is refused
SyncClient.onDocUpdatecallsownChange()beforesend(). So the refused edit is still counted inseen/times, and the next check covers it.send()drops the message and setstooLarge, but nothing stopsscheduleCheck → sendCheck. The server answers that check (it covers everything the room has, which does not include the edit), and thenonSavedsetsconfirmed >= seenand clearstimes. That makespendingSincenull and the statesaved.StatusBoxhidestooLargeonce the state issaved,isConfirmedbecomes true, andonConfirmedfires, so NoteSession stores the text with the paste as the safe replay base. The tab then posts{t:'ok', n: own}, so sibling tabs call it Saved too. The step-1 path is the same:send(encodeStep2(..))is refused, thenadoptSiblings(Infinity, true)andsendCheck()run regardless, and the receipt clearscarried.Every later small edit depends on structs the server never got. The server queues them as pending (they never show up in the note or history), yet each one is "Saved" too.
Reproduction: packages/editor/review4/toobig.test.ts (MAX_ROOM_MESSAGE mocked to 4 KiB so it runs fast; the client logic is untouched). Run:
bunx vitest run --config review4/vitest.config.ts.This is the round-3 P1 again (an edit the server rejected, called Saved, in the safe base), now on the single-tab path. Fix: the check must not cover a refused edit. For example, keep a refused edit's change number out of
confirmed, gateisConfirmed/pendingSinceontooLarge, or maketooLargesticky until the edit is actually sent. Also don't calladoptSiblings(…, sent=true)when step 2 was refused.P2: "Too large to save" is never shown in the web app
describe()returns the words, but apps/web never calls it: Editor.svelte renders onlydata-save={status.state}and the offline "stuck" line, which needsnot-saved. An online too-large paste issaving, so it shows nothing, and becomessaved(P0 above). The claim "shows Too large to save" holds only in the editor package'sdescribe(). Nothing in packages/ or apps/ handles the server'stoo_largeJSON either. It is ignored, so a server-side refusal would also end in a covering receipt.P0 at full size, real server. packages/editor/review4/e2e-big.ts
toobig 66: the realcalternal serve(head debug build), two production SyncClient tabs on the note's BroadcastChannel and a peer on another "device". Tab B pastes 66 MiB.Both tabs say Saved and both fire onConfirmed (safe replay base) for a paste the server never received.
Verified: a 60 MiB paste saves, reaches history and peers (real server)
e2e-big.ts near 60: B and A go saving → saved at 2.36 s. The server text has the paste exactly once, the history version moved 1→2, the peer's text equals the server's, and a later small edit saves. Server RSS was 26 → 288 MiB during the paste.P2: unfinished chunked messages pin server memory with no timeout and no per-connection or global bound
Sessions.pieceskeeps up to 64 MiB per joined room, per connection, until the last piece arrives or the socket/room closes. Nothing caps rooms per connection, total pieces per connection or across connections, and there is no timeout.e2e-big.ts dos 8: one authenticated socket joins 8 notes and sends 63 MiB of+roompieces to each, never the last piece.This grows linearly with rooms × sockets, so a single user (or a buggy client) can exhaust the server's memory. The downstream queues were sized for 1 MiB messages, and now each slot can hold a 64 MiB message: a connection's room inbox (
mpsc::channel(256), lib.rs), the room actor (4096) and each peer's outgoing buffer (CLIENT_BUFFER1024). The worst-case backlog behind a stalled room is therefore about 64× what it was. Suggested fixes:Boundaries are consistent: client
data.length > MAXand serverbytes.len() + msg.len() > MAXagree on the y-message size, so exactly 64 MiB is accepted and 64 MiB + 1 is refused by both. Interleaving between two tabs or two clients cannot happen: pieces are per connection and per room, andLiveSocket.sendFramewrites every piece synchronously. A disconnect mid-message frees the pieces with the connection, and step 2 resends on reconnect.Verified: rollback compatibility against the real dev code (claim 3)
packages/editor/review4/rollback.test.ts imports
LocalCopyfromgit show origin/dev:packages/editor/src/offline/local-copy.ts(dev8b30062, which is this branch's merge base), not the frozen fixture. The fixture is byte-identical to dev apart from its header comment.getAll()applies the[0,0]marker value as an empty update. Dev then compacts past 500 changes, which deletes the key range includingdirty@…, and head reopens it with the right text. Pass.R4-ROLLBACK-2: dev appends next to the marker without compacting, then head reopens:{"text":"head words dev words","dirtySince":true}. Pass.l:1, which dev ignores.NoteMeta.heldSinceis optional, so dev reads the meta records.The round-3 P3 rollback hazard is fixed.
Claim 1 (sibling receipts): R3-TAB is fixed; three remaining holes
saving/ not confirmed, both adopt and send after 2 s, and the server has the edit exactly once. There is no early onConfirmed.{"early":{"a":false,"b":false,"sa":"saving","sb":"saving"},"server_C_count":1,"a_bad":0,"b_bad":0}. Pass.fromis never confirmed. The waiting tabs adopt after 2 s, which is safe.savinglonger, andpendingNotes()stays true, so it is safe. P3 at most (a slow Saved in a hidden tab).P2: a joining tab trusts a sibling's join answer for content that sibling never confirmed (R4-JOIN)
When a new tab posts
sv, each sibling answers with its whole diff, taggedn: own, ok: ownDurable, join: true. If that sibling's own edits are all durable (ok == n), the receiver recordsdurable[from] = okfirst and then drops the edit inSiblings.add. What remains isremoteChange(), which the joining tab's own base check confirms. But the diff can carry content that the answering tab holds unconfirmed itself: a third tab's edit waiting in itsSiblings, or an offline tab's edit it forwarded over a stuck socket. That content was never sent by the joining tab, and the server may not have it.packages/editor/review4/tabs.test.ts
R4-JOIN: C's socket is stuck; C types<C>and closes. A holds<C>as a sibling edit for 2 s. D opens a first time, so it learns the lineage from its join answer and opens BroadcastChannel after syncing, and it gets<C>only from A's join answer.D fires onConfirmed (safe replay base) with
<C>in it while the server lacks<C>, which breaks "nothing enters a safe replay base without a covering server receipt". In the app the window is narrow:<C>in step 2.<C>2 s later, unless A is also closed or throttled.Loss needs a lineage reset after D stored that base and before anyone sent
<C>. Fix: a join answer should claimokonly for content the answering tab has receipts for. For example, sendn: ownonly when it holds no unconfirmed siblings or forwarded edits; otherwise dropok, and the receiver treats it like an offline tab's update and sends it itself.P3: a malformed or forged tab message is counted as saved without any receipt
R4-GARBLED: aumessage withfrom: 42, n: 'x'is applied but never counted ('x' > 0is false, soSiblings.adddrops it, and nothing callsownChange). The tab shows Saved and isConfirmed while the server never got it:{"server_has_G":false,"a_state":"saved","a_isConfirmed":true}.R4-FORGED:{t:'ok', from:77, n:1e9}followed by a real edit from 77 has the same result,{"server_has_F":false,"a_state":"saved","a_isConfirmed":true}. Any same-origin script can do this, and it could also write IndexedDB directly, so this is not a security bug. But one malformed message from a buggy future version silently skips the receipt. Validaten/from/okas finite integers and treat anything else as unknown (send it yourself).P3: a big paste is uploaded again by every other tab when the typist's receipt takes more than 2 s
The 2 s
SIBLING_WAIT_MSdoesn't depend on size. On an uplink where a big paste takes more than 2 s to upload and confirm, every other open tab of the note adopts it and uploads the same bytes again. Reproduction:e2e-big.ts resend 20(real server; the typist tab's socket sends 5 s late) gives{"saved_ms":5228,"a_uploaded_bytes":20973471}, so the idle tab A uploaded B's whole 20 MiB paste a second time. Innear 60on localhost, A became Saved only at 2.36 s, right at the deadline. Consider scaling the wait with the bytes pending, or adopting only edits whose sender is gone (no BroadcastChannel heartbeat).kill -9 (gate): pass=50 fail=0
kill_nine_never_loses_or_doublesran 50 times serially (notes_crash-97f429e8d50597f9, head debug) with two nice-19 CPU busy-loops: pass=50 fail=0. Typical run: "30 kills, 222 confirmed appends, 29 in-flight appends retried". Logs: crash/run-*.log.P3 (gate failure):
group_commit::edits_typed_during_a_write_commit_togetheris timing-flaky under loadcargo test --workspace --lockedfailed once in calternal-notes:assertion left == right failed: all 51 edits shared one transaction; left: 2, right: 1(group_commit.rs:90). Run alone 20 times with the crash loop going (load average about 10 on 12 cores): pass=16 fail=4. The test is new on this branch (709c30f). It asserts an exact transaction count that a loaded scheduler can split, so this is a test robustness issue, not lost data. But CI runs on shared runners, so it will flake there too.Claim 5 (held collaborator changes): covered, with a false-positive warning (P3)
pendingNotes()now countsclient.heldSince, andstoredPendingIds()countsheldSincein meta, written 2 s after a collaborator change is still unconfirmed. During a receipt outage the sign-out warning appears, which is what the claim says.heldgets a new entry for every remote change and empties only when a receipt covers all of them. If a collaborator types nonstop in an open note, it is never empty for long.review4/held.test.tsR4-HELD-BUSY uses production delays: a collaborator types at 20/s, and pollingpendingNotes()likeunsentChanges()does (50 ms for 3 s) never sees false.{"pendingNotes_cleared_within_3s_at_ms":null,"state":"saved"}. So signing out while someone else is typing always shows "Some changes on this device haven't been saved…" even though the server has everything. Consider counting only held changes older than a few seconds.destroy()clearsheldTimer. Closing a note within 2 s of a collaborator change arriving during an outage therefore never recordsheldSince, so a later sign-out does not warn. This is the stated "open and leave" trade-off.Re-verified on head: order through failures and bounded checks (notes crate unchanged since
a21bc05)Ran round 3's scratch tests (crates/notes/scratch/review3_lane.rs, included temporarily) with
cargo test -p calternal-notes --lib review3_ -- --nocapture --test-threads=1: 4 passed.Steady-typing lag on the perf VM HDD at 60/s (base dev
8b30062vs head6287c7a)Perf VM root@10.69.69.63 under
flock -o /root/perf-vm.lock, release builds in /root/review652-4, the same review3_lag.rs harness in both, alternating base→head then head→base, 6 rounds × 10 s, data on /mnt/b/hdd-ext4. Binary hashes are in results/hashes.txt. Per-edit wait for a covering Saved (ms):No regression. Caveat: this harness drives the room directly, so it does not exercise the round-4 change in live.rs/rooms.rs. For ordinary frames that change is one
strip_prefixand one HashMap lookup, and a sub-1 MiB message is still a single frame.Re-verified: no early Saved for any peer during a history outage (real server)
review3/e2e.ts on the head binary, scenario
all, with history.db write-locked by another process, then SIGKILL and restart:states_before_kill A=saving B=saving C=saved; confirmed_before_kill all false; confirmations_before_kill all 0; saved_after_restart_ms=699; server ONE=1 TWO=1; history rows ONE=1 TWO=1; queued 20 edits: history rows and note counts all exactly 1; peers_match_server=true. C took 88.5 s to join during the outage, the known carried-over P3. Thetypist-gonerun timed out in the harness waiting for C to sync during the outage (the same slow-join P3; the harness's limit is shorter than the join).P2: an edit typed in another tab while sign-out is in progress is wiped without a warning (claim 4)
Settings.signOut()callsunsentChanges()once. ThensignOutDevice()awaitsfinishLogout(), a network round trip of up to 3 s (AbortSignal.timeout(3000)), before it broadcastssignout. Other tabs stay fully editable during that window. When the broadcast arrives,leave()→stopNotes()→ reload → wipe deletes their copies, and there is no second check and no dialog.stopNotes()closing local copies (flush to the write-ahead list) cannot help here, because a deliberate sign-out deletes the write-ahead lists too.Reproduction: apps/web/e2e/review4-signout.spec.ts (the signout.spec harness plus one test; uncommitted). Tab 2 has note 0 open, and its socket frames to the server are dropped after a flag (a stuck uplink). The logout request in tab 1 is delayed 2.5 s. Sign out is clicked with nothing pending, and 700 ms later tab 2 types
TYPEDDURINGSIGNOUT.With a stuck uplink, the edit is gone: it is not on the server (grep of the data dir) and not on the device, and no dialog was shown. With a working uplink it usually reaches the server, so the window matters only on a flaky network, which is exactly when logout takes its full 3 s. (The webkit-390 runs of this probe failed in the probe itself,
Target page, context or browser has been closed: my page-level routeWebSocket on top of the spec's context route. They are not product evidence.)Fix options:
pendingNotes()and stored pending ids inleave()(each tab), and abort or ask when something new is pending.unsentChanges()afterfinishLogout(), before broadcasting.Related P3: on the remote-ended path (
sessionEnded),stopNotes()runs beforelocation.reload(), and the old page keeps taking key events until the new document commits. An edit typed in that window goes into a doc with no local copy and no sync, so it is lost silently. Before this change it reached the write-ahead list on pagehide. Make the editors read-only instopNotes().Verified: the server's size boundaries (scratch unit test in rooms.rs, reverted afterwards)
MAX_ROOM_MESSAGE(a 32 MiB piece plus a 32 MiB last piece) is delivered whole: 67,108,864 bytes.MAX + 1is refused withTooLargeat the last piece, and nothing is delivered.[1,2,1,2,3]). TCP ordering makes this impossible for a correct client, and the joined message would then fail to decode in the room. Worth a length or count header if pieces ever travel over anything other than one ordered socket.P2 (gate red): signout.spec.ts:287 "remote sign-out retains copies…" fails repeatedly on chromium-390 after
stopNotes()Final chromium-390 signout.spec.ts ×60: 232 passed, 8 failed (rc=1). All 8 are :287; 7 of them fail at line 307: the remaining localStorage keys include a write-ahead list key.
(The eighth was
Setup failed: 400in the fixture's second-account WebAuthn setup.) Cause: round 4'ssessionEnded()→stopNotes()→LocalCopy.destroy()now callsflush(), which writes the write-ahead list whenever IndexedDB writes are still unconfirmed at that moment.forgetDevice(keepNotes=true)deliberately keeps:wal:keys, so the key survives. That is safe for data: a different account'sclaimDevicewipes it. But the spec still asserts the old exact key set, so it now flakes. The author's 60× validation ran only :221, not :287. Either the spec should allow:wal:keys for retained notes, orstopNotes()should leave nothing pending.Gates (head
6287c7a, this host, cargo -j4, Playwright --workers=1)Verdict: do not merge
Blocker (P0): an edit over 64 MiB, or one refused in step 2, is called "Saved" about 150 ms later. It moves the safe replay base, and sibling tabs echo the Saved. Every later edit on that note is also "Saved" while the server can't integrate it. Reproduced in unit tests and with the real server at 66 MiB. The "Too large to save" words are never rendered in the app either (P2).
Also before merge:
What holds:
Starting round 5 on branch issue/652-history-fix5 from origin/issue/652-history-fix4, base
6287c7a. Merging origin/dev before implementation. I will route Saved and safe replay confirmation through one receipt authority, preserve reviewer reproductions as tests, and post gate evidence here. No PR, merge, or deployment.Round 5 root cause: client.ts captured seen/own counters in save checks even when send() had refused the update. onSaved retired those counters unconditionally. Siblings.confirm separately retired sibling edits from BroadcastChannel claims, including join-answer ok values; malformed sequence numbers could skip the ledger entirely. Those paths are being removed together.
The new receipts.ts ledger owns both Saved and replay-base eligibility. It records origin/sequence and submission coverage for each edit. Checks snapshot only submitted edits. Server packets can prove coverage (including Yjs delete sets), but only a later server receipt retires an edit. A refusal permanently excludes affected edits from confirmation during this visit. Sibling messages never grant durability. A server echo also avoids re-uploading a sibling update merely because its receipt is slow; fallback wait scales with update size.
Branch issue/652-history-fix5 started at
6287c7a; origin/dev merge reported Already up to date. These are source findings and implementation decisions; gate results will follow.Using frontend-testing-debugging for the rendered refusal and sign-out flows. Browser plugin not available; the required repository Playwright workflow is the fallback. Flow: open editor -> refuse large edit or begin sign-out -> visible refusal / every tab read-only, with copies retained until the authorised wipe.
Round 5 findings and evidence:
The round-4 group-commit failure was a test synchronization race. stall() queued a pause without waiting for the writer to enter it, so a prefix of the 51 edits could already be collected in that writer batch, and the suffix could commit separately. A test-only entered-pause acknowledgement now makes the boundary deterministic. The focused gate passed 20/20; the full group_commit suite, including the reviewer's four lane reproductions, passed.
The chunk assembler now reserves declared bytes before allocation, permits one 64 MiB message per connection and 256 MiB across connections, checks piece sequence numbers and length, and expires idle assemblies after 15 seconds. Focused core/server unit tests passed, including exact-64-MiB acceptance, oversize refusal, duplicate/missing/out-of-order pieces, per-connection/global budgets and expiry. Room transport queues now have byte limits as well as message limits. A further audit found retained history/inflight payloads also need byte budgets; that part is being completed before final gates.
The first editor suite passed 233/235. All copied round-4 editor reproductions and the 10,000-case randomized model passed. The two remaining failures were old status/check-count expectations and have been updated; final rerun is queued. The stricter rule now also keeps collaborator state from displaying Saved before its receipt, while sign-out warnings ignore ordinary collaborator changes younger than two seconds.
The independent implementation audit found another instance of the same class before final validation: server packets queued behind IME could run after reconnect and be mistaken for proof about the new server. A pre-crash unjournaled packet could therefore enter a restarted connection's receipt coverage even though its opening sync omitted those bytes.
The fix records packets as observed immediately, while separately recording whether they have been applied to the document encoded by sync step 2. Deferred packets carry a connection generation. After reconnect their bytes must be resent on that connection before its receipts can cover them; old packets never populate the new server's coverage shadow. Destroy and lineage recovery flush deferred changes before closing persistence or capturing replay text. New permanent tests cover queued packets across crash/reconnect and an initial cached snapshot whose receipt arrives before composition ends. Old websocket callbacks are now also ignored by socket identity.
A related server path was found in SyncStep2: missing prerequisites could be skipped and yet clear resync's held save checks. It is being changed to keep the checks held until a complete resend, including cross-writer dependencies, and has a permanent protocol regression.
The class audit also removed stale membership authority. A closed/reopened note used to restart its check IDs, and queued old room replies could still be delivered after a replacement membership. Check IDs are now monotonic across the page; server event generations reject stale join/data/left events, and the live wire is being tagged with a client membership nonce so already-written stale packets cannot open or confirm a replacement room.
Both independent UI Saved defaults were removed: an initial editor and a note preview now have unconfirmed state, and only the receipt authority's subscription can render Saved. Refusal codes are persisted with note metadata and preserved during automatic lineage recovery; a reload cannot bypass a permanent refusal.
The latest completed editor run passed 244/244 with TypeScript check exit 0. Further nonce/persisted-refusal changes are awaiting their fresh final rerun. Server Step2 tests reproduced both skipped-prerequisite and parked cross-writer cases before the fix; their old code sent Saved while bytes were still missing. The fixed server keeps resync checks held until complete integration and journals parked input so a later dependency cannot release text absent from history.
Removed durability-grant paths, now routed through receipts.ts:
The remaining NoteSession base timer rechecks the authority immediately before storing text; it cannot independently confirm state. Server snapshots and live updates only establish submission coverage and still need a later durable receipt.
10. Editor.svelte's initial and note-preview/reset Saved defaults. Preview state cannot grant Saved; only the authority's live status subscription can.
11. Reopening a note or automatically changing lineage cannot clear a refused edit: the refusal code is persisted before initial publication and preserved during recovery.
12. Old-connection IME callbacks and old membership/socket packets cannot supply coverage for a replacement connection. Deferred bytes are observed immediately, excluded from opening sync until applied, and must be resent on the current connection if their generation changed.
Verification status: local gates and browser feedback are still queuing through the required three-slot wrapper while other jobs occupy the host. The perf VM commands are likewise waiting under /root/perf-vm.lock. No locks, other processes or priority markers have been bypassed or stopped.
Completed evidence so far: fmt check exit 0; focused retry-memory 6/6, both Step2 coverage regressions 2/2, core byte-queue tests, and server room/chunk tests passed. A nonce-aware calternal binary built successfully. The last completed editor suite passed 244/244 and TypeScript check passed; final persisted-refusal/nonce changes still need the queued fresh full suite. Svelte-check passed with 0 errors and 13 existing warnings before those last small changes.
The source audit is closing the final retained-command byte-accounting gap, including commands deferred during file writes. The full workspace x3, loaded crash x50, real-client, browser x60 and perf gates remain pending; no final success is claimed.
The final authority audit found one more grant path: automatic lineage recovery captured unsaved text in an onSynced closure, cleared the old LocalCopy, and reset pendingSince to null before making the replacement client. With sync step 2 held behind IME, the replacement could receive a server receipt and show Saved before replaying the captured text. Closing or reloading during that window could lose the closure-only recovery text. This is source evidence in NoteSession.recover; the focused reproduction is queued through the build slot.
The fix is a persisted recovery intent written before the old copy is cleared, plus an explicit unsubmitted obligation in the receipt authority. Initial replacement-server receipts cannot retire that obligation. Only applying/submitting the replay and then receiving its covering receipt can clear the intent. Reload restores the intent, and stale sibling metadata writes must not erase it. This path is included in the removed-authority inventory and will have permanent recovery/IME/reload tests.
The final Rust source is unchanged by this client fix. Its full workspace gate has now passed three times, strict Clippy and fmt passed, both real-SyncClient integration tests passed, and the loaded crash50 gate is running. The real-SyncClient check will be repeated after the recovery client fix is frozen.
Real-server paste and chunk-memory reproductions passed on the built round-5 server. These cover the full 66 MiB refusal, accepted 60 MiB paste, delayed 20 MiB owner upload and eight unfinished-message attempts. The client recovery-intent fix is still being completed, so these are focused-path results rather than a final completion claim.
Binary: 332837fa7dd4975c6c3e51323e51ac4353064072e03094bbe3fbb196ae67a168 /home/kayg/Developer/calternal-wt-hist/target/debug/calternal
Verbatim results:
The final Saved-path audit found another unconditional claim: Vim's :w command always said Saved, including after offline edits or a refused paste. The command now reads the same receipt-backed status as the note status line. A permanent test checks a real receipt, an offline edit and the Too large to save refusal. This is the seventeenth removed grant path.
The crash gate completed 50/50 under two recorded CPU load workers. The perf VM completed six alternating base/head pairs at 60 edits/s on its HDD: median round p95 was 184.70 ms for base and 187.48 ms for head (+2.78 ms, 1.5%). Both kept making durable progress while typing; this is not a zero-latency-change claim. Full gate output and measurements will be posted with the final head.
The recovery bypass is fixed and its focused gate passed. Before replacing the old document, the client commits a recovery intent containing the source lineage, safe base and local text. That intent adds an unsubmitted obligation to the one receipt authority, so the replacement's opening receipt cannot announce Saved before replay. Replay uses one atomically stored Yjs update with its prerequisites, making concurrent and reopened replay idempotent. Target WALs are preserved. Recovery remains read-only until a covering server receipt and an explicit local snapshot commit complete. Conflicts and capacity failures stay visible and retain the source copy. Closed-note sign-out checks use an atomic recoverySince summary that stale tab writes cannot erase.
The permanent tests cover IME-held replacement, reload before replay, reload after server apply before receipt, concurrent deduplication, retained unreceipted target bytes, missing replay prerequisites, unresolved conflict copies, refusal persistence and storage capacity refusal. The randomized model also now includes outside-document recovery obligations; its safe-base oracle snapshots independently observed edit identities.
Verbatim focused gate output:
The full editor and real-server gates are now rerunning against this frozen client.
Issue 652 fix5: Rust gates and steady-typing evidence
All local heavy commands used the required build-slot.sh wrapper. Cargo used -j4 and CARGO_TARGET_DIR=/home/kayg/Developer/calternal-wt-hist/target. Harness exit codes and calculated aggregates below are labelled separately from verbatim process output. Verbatim excerpts are explicitly non-contiguous where stated. Full captured stdout/stderr is preserved as byte-for-byte <=37,500-byte chunks in verbatim/, with hashes and concatenation order in verbatim-manifest.json. No commits or pushes were made by this agent.
Source/provenance: parent HEAD
6287c7a870plus the uncommitted changes in final-source.patch/final-status.txt. source-manifest.json records the 113 core/notes files used for the perf build; every staged file was compared to the final formatted local source and matched. Rust source was frozen for the gates. The real SyncClient dynamically imports TypeScript; root may replace that section with a later final-TS rerun before posting.Exact outer runner for the full local gate sequence:
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Formatting
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Harness exit code: 0. Captured stdout/stderr was empty (there is no process output to quote). Formatting had first been applied with cargo fmt --all.
Clippy
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Harness exit code: 0. Verbatim final line; full output: clippy.log and its verbatim chunks.
Workspace, three consecutive runs
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Run 1: harness exit code 0. Calculated aggregate (not a Cargo output line): 77 suites; 830 passed, 0 failed, 4 ignored. Below are non-contiguous verbatim test-result lines with nonzero passed/ignored counts from workspace-1.log. Full output is split in the manifest.
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Run 2: harness exit code 0. Calculated aggregate (not a Cargo output line): 77 suites; 830 passed, 0 failed, 4 ignored. Below are non-contiguous verbatim test-result lines with nonzero passed/ignored counts from workspace-2.log. Full output is split in the manifest.
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Run 3: harness exit code 0. Calculated aggregate (not a Cargo output line): 77 suites; 830 passed, 0 failed, 4 ignored. Below are non-contiguous verbatim test-result lines with nonzero passed/ignored counts from workspace-3.log. Full output is split in the manifest.
The four existing ignored tests were the internet-dependent Unsplash client test, reload_speed, slow_disk_long and slow_disk_matrix. The latter two are perf measurements; steady HDD typing was measured separately below.
Group-commit stability
Command (cwd /home/kayg/Developer/calternal-wt-hist):
The harness executed this exact command 20 times:
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Verbatim focused.py stdout (its JSON lines report each child command exit code, not Cargo stdout):
Verbatim Cargo stdout for the first and twentieth runs; all 20 full logs are preserved as group-loop-*.log and verbatim chunks:
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Verbatim final suite result; full output: group-commit.log. The suite includes the four permanent reviewer lane reproductions and both Step2 missing-dependency regressions.
Root cause: stall() merely queued a pause, so the writer could pre-collect a prefix of the edits before reaching it. The test now awaits a reached-pause acknowledgment before queueing the 51 edits, and waits for a second reached pause before observing the transaction counter (which is incremented after receipts). Both new Step2 tests were observed failing before the protocol guard was fixed: step2-red.log and step2-parked-red.log preserve that output.
Real SyncClient integration
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Harness exit code: 0. Full captured stdout/stderr verbatim:
Crash gate, 50 serial runs under two CPU workers
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Recorded worker process metadata (verbatim ps output):
Worker summary artifact (calculated from recorded /proc stats, not test stdout):
Both owned workers were terminated/reaped normally after run 50. No processes belonging to other tasks were terminated. Test executable SHA256: e2a6581858f389dc18e468442115086f081c20b920052d0b6f2d4ee9f3ed32c4
Command (cwd /home/kayg/Developer/calternal-wt-hist):
That command was executed 50 times (600s harness timeout per run). Harness summary artifact, not test stdout:
Verbatim result lines, identified by captured log filename; full output for each run is preserved in the raw chunks:
crash-01.log:
crash-02.log:
crash-03.log:
crash-04.log:
crash-05.log:
crash-06.log:
crash-07.log:
crash-08.log:
crash-09.log:
crash-10.log:
crash-11.log:
crash-12.log:
crash-13.log:
crash-14.log:
crash-15.log:
crash-16.log:
crash-17.log:
crash-18.log:
crash-19.log:
crash-20.log:
crash-21.log:
crash-22.log:
crash-23.log:
crash-24.log:
crash-25.log:
crash-26.log:
crash-27.log:
crash-28.log:
crash-29.log:
crash-30.log:
crash-31.log:
crash-32.log:
crash-33.log:
crash-34.log:
crash-35.log:
crash-36.log:
crash-37.log:
crash-38.log:
crash-39.log:
crash-40.log:
crash-41.log:
crash-42.log:
crash-43.log:
crash-44.log:
crash-45.log:
crash-46.log:
crash-47.log:
crash-48.log:
crash-49.log:
crash-50.log:
Steady typing on the perf VM HDD
Command (cwd /root):
That remote command ran via ssh -o BatchMode=yes root@10.69.69.63, with stdout/stderr redirected to /root/history-fix5/perf.log.
Remote build command (cwd /root/history-fix5/final-head):
Command (cwd /root/history-fix5/final-head):
Baseline: reviewed dev
8b30062, reusing the recorded review4 baseline binary. Head: final frozen core/notes source. Measurement logic is identical to review3_lag.rs; head changes only the Joined sender type to room_queue::Sender. Six rounds alternate base→head then head→base. Each executable ran this command with its respective revision and round label:Command (cwd /root/history-fix5/final-head):
Binary hashes, verbatim:
Build-source hashes, verbatim:
Raw per-run JSON stdout, verbatim (each filename identifies the revision/round):
base-hdd60-r1.json:
head-hdd60-r1.json:
base-hdd60-r2.json:
head-hdd60-r2.json:
base-hdd60-r3.json:
head-hdd60-r3.json:
base-hdd60-r4.json:
head-hdd60-r4.json:
base-hdd60-r5.json:
head-hdd60-r5.json:
base-hdd60-r6.json:
head-hdd60-r6.json:
Calculated comparison (not verbatim process stdout): median per-round p95 was 184.703ms base vs 187.483ms head (+2.780ms, about +1.5%). Worst edit wait was 319.592ms vs 327.179ms. Checks covered during typing were 369/371 vs 372/374; every measured edit received its final covering Saved in every round. Maximum final Saved after typing stopped was 29.243ms base vs 11.133ms head. No sustained queue growth appeared. This sample does not establish literally zero added latency; tails vary by round. The harness drives Notes/rooms directly and does not measure websocket chunk-parser or browser rendering overhead. All raw data, disk identification, hashes and computed summary are under perf/.
Stable final browser-gate binary
Command (cwd /home/kayg/Developer/calternal-wt-hist):
Harness exit code: 0. Verbatim final build output:
Stable binary metadata artifact (hash computed after the successful build):
Final frozen-client gates passed. The 221-file client source/test hash manifest was unchanged across this run. Local commands ran inside build-slot.sh; Cargo used -j4 and the requested target directory. The disk-full messages below are the real SyncClient tests' deliberate SQLite refusal injection; host disk was not full. All four large-message probes used the final explicit server binary SHA11ef218401c386eb7f364d73c1118a0c8bd4827b9299a6db933477b9d853b092.
Commands: bun run --cwd packages/editor test; (cd packages/editor && bunx vitest run test/receipts.test.ts --reporter=verbose); bun run --cwd packages/editor check; bun run --cwd apps/web check; CALTERNAL_SYNC_BRIDGE=$PWD/packages/editor/integration/history-peer.ts cargo test -j4 -p calternal-notes --locked independent_652_real_syncclient -- --nocapture --test-threads=1; bun integration/review4-big.ts <toobig|near|resend|dos> <66|60|20|8>.
Verbatim captured gate output:
Browser gates remain in progress.
The screenshot review caught an actual remaining refusal-display bug: the correct Too large to save text existed in the DOM and passed Playwright toBeVisible, but appeared after a height:100% editor and was clipped below the viewport. The attached 390px screenshot shows the refused edit with no visible warning. The refusal status is being anchored above the toolbar, and the permanent browser regression now requires toBeInViewport as well as visible words, including after reload. Ordinary collaborator-delay warnings keep their existing timing.
Issue #652 fix5 raw gate output: clippy, part 1/1. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-1, part 1/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-1, part 2/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-2, part 1/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-2, part 2/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-3, part 1/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: workspace-3, part 2/2. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: crash-50, part 1/1. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
Issue #652 fix5 raw gate output: group-20, part 1/1. This supplements the gate report in comment 63072. Captured stdout/stderr follows verbatim; file labels identify run boundaries.
The refusal viewport fix is now verified on the 390px Chromium cases with and without BroadcastChannel, including reload. Both tabs show the actual words inside the viewport. The normal collaborator-delay indicator is unchanged. The sign-out tests also verify contenteditable=false before the delayed logout completes and reject real keyboard typing.
After the UI fix, wrapped
bun run --cwd apps/web checkexited 0. Verbatim final output lines:The complete browser gates are still running.
A final targeted audit reproduced a separate recovery race. A remote REMOTE insertion was already covered by a server receipt, but was still waiting behind IME. The visible document and delayed stored base both said BASE. Reseeding the server from its durable REMOTE/BASE text then made the text replay insert REMOTE again. Saved was truthful in this case; the replay source base was stale relative to the authority-confirmed held text.
The narrow fix captures the old receipt authority's fully-confirmed decision before draining IME, then uses the post-drain text as the replay base. No unreceipted edit can enter that path. Existing unresolved recovery obligations still retain their durable conflict-copy behavior. Permanent tests will cover this case and the short fully-confirmed base-write delay window. The queued long browser repetitions were stopped before continuing on an old bundle; client gates will rerun after the fix. Rust source and perf inputs are unchanged.
Verbatim artifact-only reproduction output before the fix:
The receipted IME replay race is fixed. Recovery now checks the old receipt authority before and after draining IME. Only when both checks confirm every observed edit does it use the drained text as the source base. Pending edits and existing recovery intents keep their conservative path. This also covers an immediate lineage reset inside the normal 100 ms delayed base-write window.
Two permanent NoteSession regressions verify that durable remote text appears once after reseeding. This is removed path 18: unconditional use of the delayed stored base despite a newer fully-confirmed in-memory document. The invariant is documented in code and the ADR. Full client/browser gates are rerunning on the new frozen source; Rust source is unchanged.
Verbatim focused gate output:
Final client gates after the confirmed-base close/reopen fix. These supersede the earlier client gate report. Final editor source/test hashes stayed unchanged during the complete 261-test run. The 10,000-case model runs inside that suite; its separate unchanged receipt-module run is also quoted below. All local heavy commands used build-slot.sh. The real SyncClient tests deliberately inject SQLite disk-full errors; those messages are expected evidence of refused history writes.
Commands:
Verbatim final complete editor output:
Verbatim separate property output:
Verbatim focused final recovery and TypeScript output:
Verbatim final real SyncClient output:
Verbatim final large-message probes:
Final frontend check exited 0 after the immutable browser bundle build. Verbatim final lines:
The four-project browser suite and both 60-repeat sign-out gates are now running against the final immutable frontend and server binary SHA11ef218401c386eb7f364d73c1118a0c8bd4827b9299a6db933477b9d853b092.
The last sign-out audit found a concrete read-only bypass: y-codemirror.next undo/redo mutates Y.Doc before CodeMirror transaction filters run. Default shortcuts, Vim u/Ctrl-r and the app undo action called that raw command. A real Chromium test with genuine undo and redo history proved that Ctrl+z removed an edit during delayed logout even though contenteditable=false and aria-readonly=true. Two unit regressions also failed before the fix, including the window before a sibling receives its freeze notification.
All those paths now use one guarded history export. It checks readOnly and the editor's synchronous device-permission callback before changing Yjs; normal transactions use that same callback. Cancellation preserves undo/redo history. Permanent editor and Vim tests cover both directions, and the browser sign-out regression now exercises nonempty history.
The old long browser runs were stopped using only their recorded process IDs (18 Chromium and 24 WebKit cases had passed; no failures). Final client checks and a fresh immutable browser bundle are required before restarting them. Rust source and perf inputs are unchanged.
Verbatim unit reproduction output before the fix:
Final client gates after closing the direct-Yjs undo/redo bypass. This supersedes the editor/TypeScript/frontend/real-client sections of comment 63166; the large-message probes and frozen Rust gates remain unchanged. All local heavy commands used the required build slot, Cargo -j4 and the requested target directory. The complete editor suite includes the unchanged 10,000-case randomized receipt model.
Commands: bunx vitest run test/editor.test.ts test/vim.test.ts --reporter=verbose (editor cwd); bun run --cwd packages/editor test; bun run --cwd packages/editor check; bun run --cwd apps/web check; CALTERNAL_SYNC_BRIDGE=$PWD/packages/editor/integration/history-peer.ts cargo test -j4 -p calternal-notes --locked independent_652_real_syncclient -- --nocapture --test-threads=1.
Verbatim final gate output:
The final browser bundle is rebuilding for a fresh targeted undo/redo check, four-project suite and both 60-repeat sign-out gates.
The browser regression found a second undo entry point: yCollab handles native beforeinput historyUndo/historyRedo with raw Yjs calls. Guarding keyboard, Vim and app undo alone did not stop this path. The focused native-event regression reproduced two failures before the fix. I added an earlier native history handler that routes both operations through the same synchronous session/device permission check and consumes the event. The focused editor and Vim run now reports 2 test files passed, 29 tests passed. Full client checks and the real-browser regression are running before the repeated browser gates.
Final client checks after guarding native undo and redo. No client edits are planned after this run. Svelte warnings are the existing 13 warnings in 8 files. The disk-full errors in the real SyncClient test output are deliberate fault injection; both tests pass.
Verbatim gate output:
Additional final large-message and explicit randomized-model gate output. The model is also included in the final 265-test editor run. These runs use the same receipt and transport sources as the final client manifest; the later undo guard changes only editor commands. The 60 MiB paste RSS figure includes full Yjs documents and copies in this harness; it is not a measurement of queue budgets alone.
Large-message gate script (run inside the required build slot):
Verbatim output:
Explicit property run, verbatim output:
The final WebKit sign-out regression is currently blocking the long browser gates. Chromium passes the frozen undo/redo and typing assertions on the final product build (9.2 seconds). WebKit stalls before the logout request is entered and before a discard dialog appears, so it has not reached the undo assertion. Replacing Playwright request interception with a delayed wrapper around the real logout fetch did not resolve that earlier stall. I am tracing Settings/unsentChanges and tab visibility; no long test run or product change has been made on the strength of a passing Chromium test alone.
The native undo/redo/typing sign-out regression now passes in both Chromium-390 and WebKit-390: 2 passed (33.2s), with real undo and redo items already receipted before sign-out. Activating the initiating tab before clicking Settings/sign-out, then activating the sibling before typing, resolved the WebKit test stall; this matches the real user tab sequence. The fixture still delays and sends the real logout fetch.
I also corrected an existing false Settings sentence, "Nothing on this device is deleted", to say sign-out clears this app’s data from the device. This is relevant to the required visible sign-out behavior. The final browser build and check will include this sentence before the full gates start. Receipt, transport, server and undo behavior are unchanged.
Verbatim regression output:
The broad browser run timed out in editor.spec.ts:289, the existing Chromium IME test. Sanitized trace evidence shows opening both notes and creating the CDP session completed, but the first Input.imeSetComposition command never returned before the 30-second test timeout. The test had not sent its collaborator edit or reached receipt assertions. I am activating the composing tab before the CDP command and will run the IME test at both Chromium widths before rerunning the broad gate. Product code and the immutable app build are unchanged; independent sign-out repetitions continue.
Fresh final-build desktop evidence: the server too_large refusal displays "Too large to save" above the toolbar at 1440 pixels. I inspected this capture, in addition to the mobile capture already attached in comment 63102. The refused edit remains visible in the editor.
Browser gate status: the independent 60-repeat sign-out runs remain green (Chromium 214/240 cases and WebKit 100/240 at this update). The broad gate remains blocked by the IME test: bringing the composing tab forward did not resolve the stalled CDP composition command. No product fix has been inferred from that timeout. A bounded comparison of plain inputs and the real editor is queued through the required build slot using the normal Playwright harness. A standalone probe could not create its first usable page, so it produced no IME result and is not counted as evidence about the app. Product code, the app bundle, the server binary and the sign-out test source remain frozen.
The minimal Playwright probe found an environment cause before any app code or IME command: Chromium crashes while rendering a plain textarea because it cannot load the Fontconfig configuration, then exits with SIGTRAP. This explains why the app can render its bundled Latin fonts while the Kana composition command loses its browser. The broad browser gate will use a valid font configuration set only in this job’s external scripts after sourcing the required browser environment. Shared configuration and global fonts will not be changed. The actual IME regression will be rerun with its assertions intact; no skip or product workaround is being added.
Verbatim sanitized browser process evidence:
The independent sign-out runs remain valid: Chromium completed 240/240, and WebKit is at 120/240 with no failures.
The Fontconfig control and the original actual-editor IME test both pass with only this job’s private font environment changed. No product workaround, test skip, focus emulation or change to the original IME test remains. The clean four-project browser run is underway.
Verbatim proof and successful IME gate output:
The clean broad run passed the original IME case, then found a timing race in the new review-4 sign-out fixture. Its fixed 2.5-second logout delay expired before keyboard assertions finished on the loaded host. The Chromium-1440 normal-uplink case reached sign-in during a text assertion; the trace did not show an accepted edit changing the frozen note.
The fixture now holds logout until the 700ms wait and real undo/redo/typing proofs finish, then releases the original request in finally. Actual network dispatch gets the normal bounded three-second signal, so time spent making assertions cannot turn the request into an already-aborted offline logout. The fixture also checks the real logout response and that the retained server session is rejected. Product code and the independent signout.spec repetitions are unchanged. The two affected browser-width cases are being rerun before restarting the full broad gate.
The fixed logout window passes both focused cases: Chromium-1440 and WebKit-390. Both retain the original 700ms wait and real undo/redo/typing assertions; after release they check the real native logout response is 2xx and the retained owner session receives 401. The fixture change does not alter product code or the independent signout.spec repetitions. The full four-project gate is restarting on the same immutable app bundle.
Exact script, run through the required build-slot wrapper:
Verbatim output:
Final browser gate output for #652, part 1 of 6. This is a verbatim continuation of the external gate report.
Final browser gate output for #652, part 2 of 6. This is a verbatim continuation of the external gate report.
Final browser gate output for #652, part 3 of 6. This is a verbatim continuation of the external gate report.
Final browser gate output for #652, part 4 of 6. This is a verbatim continuation of the external gate report.
Final browser gate output for #652, part 5 of 6. This is a verbatim continuation of the external gate report.
Final browser gate output for #652, part 6 of 6. This is a verbatim continuation of the external gate report.
Finished round 5 on branch issue/652-history-fix5. Head:
2bbdffbc2e.The branch starts at fix4
6287c7a870. Merging origin/dev8b30062e1creported already up to date.Saved and the safe replay base now share the receipt authority in packages/editor/src/sync/receipts.ts. Refused edits remain visibly unsaved across reload and recovery. Sibling messages can only delay Saved. The invariant is documented in code and ADR 0020. The server bounds partial chunks and queues; sign-out freezes local and sibling editing, including direct Yjs undo and redo. The review reproductions are permanent tests.
Removed or routed through that authority and the sign-out permission guard:
Removed independent Saved/base decisions and unsafe editing paths. Items 1–19 use the receipt authority; items 20–21 use the shared sign-out permission guard:
The remaining NoteSession base timer rechecks the authority immediately before storing text; it cannot independently confirm state. Server snapshots and live updates only establish submission coverage and still need a later durable receipt.
All required gates completed successfully. Counts below are calculated aggregates; the code blocks are verbatim, non-contiguous output excerpts. Full logs are linked below.
Formatting: cargo fmt --all --check exited 0 and produced no output.
Strict Clippy:
Workspace tests ran three times: each run had 77 suites, 830 passed, 0 failed and 4 existing ignored tests. Notes-suite footers from those runs:
The crash test passed 50/50 under recorded CPU load. Last run:
The formerly flaky group-commit test passed 20/20; the group suite also passed 14 tests. Last isolated run:
Both real-SyncClient tests passed with the bridge required:
Editor unit suite, including the 10,000-case randomized model:
Explicit property run:
Svelte checking has 0 errors and 13 existing warnings:
Browser gate broad:
Browser gate chromium60:
Browser gate webkit60:
The broad run selected all four projects. Its 29 existing skips are: PWA project selection 12; signed-out PWA service-worker routing fixme 1; phone margins 2; phone list-pane switching 8; unavailable WebKit Layout Instability API 2; Chromium-only CDP IME 2; Chromium software-passkey re-sign-in 2. Neither 60-repeat sign-out run skipped any cases. Every gate command exited 0. Product and executed sign-out source hashes match across all runs; the full browser report explains the only unexecuted-spec differences.
Steady typing on the perf VM ran six alternating baseline/head pairs under flock. Median per-round p95 was 184.703ms baseline and 187.483ms head, a measured increase of about 1.5%. Every measured edit reached a covering receipt; no sustained backlog appeared. This harness measures Notes/rooms, not browser rendering or websocket parsing. Verbatim per-run JSON:
base-hdd60-r1.json
head-hdd60-r1.json
base-hdd60-r2.json
head-hdd60-r2.json
base-hdd60-r3.json
head-hdd60-r3.json
base-hdd60-r4.json
head-hdd60-r4.json
base-hdd60-r5.json
head-hdd60-r5.json
base-hdd60-r6.json
head-hdd60-r6.json
Full verbatim Rust gate output is in comments 63089–63097, with the gate and perf report in 63072. Final client output is in comment 63201, and explicit property and real large-message output is in 63206. Final browser output is in 63367, 63370, 63372, 63374, 63376, 63378.
All evidence stays in issue comments or outside the repository. No PR was opened, and nothing was merged or deployed.
Independent history durability round 5 review started. Reviewing detached head
2bbdffbc2e(author branch issue/652-history-fix5), against origin/dev8b30062e1c, especially the delta from6287c7a. I will not commit, push, merge, or deploy. Findings and gate output will follow here.Round 5 independent review progress: fmt and strict workspace/all-target Clippy have passed. Workspace tests are compiling in the required local build slot. I independently grepped the whole web/editor client: the active Saved decision is in receipts.ts, and the three NoteSession base writes are guarded by the authority. I am still reviewing the correctness of the evidence supplied to it.
The 50,000-case property extension adds server bytes queued behind IME, sign-out cancellation followed by more editing, and stale receipt delivery after a connection generation changes. The earlier probes are copied for rerunning; the offline-open assertion now follows this redesign's conservative initial Not saved behavior, the malformed sibling assertion expects rejection, and the joining probe counts confirmations only once its relevant edit is visible.
The perf VM run is currently waiting for /root/perf-vm.lock behind existing jobs, some queued for more than an hour. I have not interrupted them. The independent run has its own source snapshots of origin/dev and
2bbdffband will build and run alternating base/head measurements under that lock.P2 finding: cancelling one sign-out can unfreeze another sign-out's sibling editors.
apps/web/src/lib/wipe.ts:234-252 stores one owner/expiry in calternal.signing-out. Tab A begins sign-out and is still showing its discard warning. Tab B begins its own sign-out, overwriting the owner, then clicks Cancel. B removes the only freeze record. The storage handler calls resumeNotes in A and C, and noteEditingAllowed in C becomes true even though A never cancelled. A can still complete sign-out and wipe newly accepted C edits. The same gap is possible before A's next 10 second renewal.
Evidence: I executed the exact wipe.ts implementation in three separate page realms, stubbing imports/browser plumbing and timer scheduling only. Real shared storage events were drained after each action. The invariant assertion failed:
The four original peer/failed-history packet probes in the same command all passed. I am also running an actual-browser reproduction and will append its result. The fix needs to preserve every outstanding sign-out owner's freeze until that owner cancels or expires; one tab's cancellation must not remove another tab's active exclusion.
Independent review update: the full editor unit suite passed with my extended 50,000 x 100-action receipt model (265 tests, 31 files), editor TypeScript passed, and svelte-check passed with the same 13 warnings. Real SyncClient: 2 passed. Group commit: 20/20 passed. The strengthened original packet probes first establish a valid initial covering receipt, then inject the failed-history update/snapshot; all 4 passed.
The copied sibling, joining, closing-mid-receipt, malformed-message, refused-paste, refused-offline-resend, rollback and upload-storm probes passed. One old latency assertion failed: R3-DEBOUNCE measured peer_own_saved_ms=1022 against a <1000 ms assertion during 20 updates/s from a peer. This is a status-latency observation, not evidence of premature Saved or data loss. The new definition also waits for remote edits observed after the own edit. I will keep this failed gate visible and assess it separately from the HDD receipt timings.
Browser, real large-message and 50x loaded crash runs are now queued behind the shared build-slot train (active PID 1757483). The perf VM also still has its earlier lock owner and other waiting jobs. I have not bypassed either queue or touched their processes.
The shared local train is still running, so I moved two remaining groups to isolated processes on staging (10.69.69.192): the already-built head Rust crash test and the real oversized/accepted-paste probes. This is test execution against private temporary servers, with no service deployment or configuration change. The copied Rust binaries' SHA-256 hashes match the local gate binaries. Staging remains at 39% disk, below the required 60% limit. The two CPU-load processes belong to this test script and their PIDs are recorded; its finally block terminates only those processes.
The crash test is passing so far. The large-message probes and alternating client status/covering-receipt timing run will wait until that artificial load ends. The browser gate remains queued through the required local slot wrapper. The HDD performance gate remains queued through /root/perf-vm.lock.
Independent review, round 5 (head
2bbdffb): do not mergeSaved and the safe base are correct inside the client. I found no path to Saved or
onConfirmedwithout durable coverage. Two new blocking problems:The perf gates show no regression. The full findings, reproductions, model results and lag table follow.
Continuation (second reviewer, 2026-10-21 19:10–, same head
2bbdffb)P2 above: confirmed independently
Code read:
wipe.tskeeps onecalternal.signing-outvalue (owner expiry).beginSignOut()in tab B overwrites A's owner.cancelSignOut()in B then removes the key because the owner is now B. Every other tab'sstoragehandler runsupdateFreeze(), sees no freeze and callsresumeNotes(). A only re-freezes at its next renewal (FREEZE_MS/3).pagehidein B goes through the samecancelSignOut()path. Re-ranbun test review2/signout-freeze.test.ts: still fails,Expected: false, Received: trueat line 47. The browser reproe2e/review5-signout.spec.ts(chromium-390) is queued in the local build slot; result below.P1 (new): a retryable join error permanently marks the note "Could not save", on this device and in sibling tabs
packages/editor/src/sync/client.ts:144:this.transport.onError?.((code) => { this.receipts.refuse(code); this.publish() }).packages/editor/src/sync/live.ts(new in this branch):errorsfire for everyjoin_failed, including retryable codes such astoo_many_requestsor a room load error, and for everyroom_error. This happens before the transport decides to retry (if (this.wanted) this.retry = setTimeout(() => this.connect(), 1000)).receipts.refuse()turns any code that is nottoo_largeinto a permanent'error'.note.ts:265-275persists it to the meta store andlocalStorage[calternal-note-<id>:refused].publish()broadcasts{t:'no'}, so sibling tabs refuse too. Nothing ever clears it: grep finds no reset path.sendCheck()returns early once refused, so no further receipts are ever requested.Editor.svelte:459) forever, across reloads. Saved and the safe replay base never advance, and sign-out always warns. This is not premature Saved; it is the opposite failure, and it is permanent and visible./home/kayg/codex-jobs/history-review5/r5-transient/transient.ts. It opens 128 notes on one socket, so the 129th join getsjoin_failed too_many_requests. One note is then closed, LiveSocket retries by itself, and the user types:too_large, and a server refusal of specific bytes, should enter the receipt ledger as a refusal. Join/room errors should leave edits pending and retry.P1, second trigger: a history outage (disk full) makes the refusal permanent after the disk recovers
crates/notes/src/room/actor.rs:157-165(new in this branch) sendsCustom(102, code)for anyRoom::messageerror. Before this branch the server only dropped the client, and the client rejoined and resynced. During an outage,admit_retained→settle_one→rewrite_allreturns Err after 3 retries once 1024 changes are in flight (MAX_IN_FLIGHT). It also errors when the global retained budget is exhausted (too_many_requests). The client'scase 'refused'→receipts.refuse(code)→ a permanent'error'./home/kayg/codex-jobs/history-review5/r5-diskfull/diskfull.ts). The disk fills, 3000 keystrokes are typed (~3 ms apart),rmfrees the disk, and the user types once more after 40 s:The server ends up with every keystroke and the post-recovery edit, yet the note says "Could not save" for good. With 1200 keystrokes the outage is handled correctly: no Saved while the disk was full, and Saved again after recovery. So the safety half works; the permanent refusal is the bug.
Property model: author's model reviewed, independent SyncClient model added
The author's model (
test/receipts.test.ts, extended above to 50,000 x 100 actions) drives only theReceiptsclass. Its oracle mirrors the ledger's own check sets. It never runsSyncClient, real Yjs bytes, the server's volatile/durable split, BroadcastChannel or transport errors, and it checks safety only, never liveness. "Sign-out" is one boolean, and "server restart" keeps every token any tab saw receipted.New model:
packages/editor/review5/model.test.ts(uncommitted; standalone bundle/home/kayg/codex-jobs/history-review5/r5-micro/model-bun.ts).SyncClientwith real Yjs, 1–3 tabs on a BroadcastChannel stand-in, and a server that keeps volatile state, an ordered log and a durable prefix. Save checks are answered only once the durable prefix passes the check's log position. Updates over a size limit are refused (102plus close).onConfirmed, and after every step,Y.snapshotContainsUpdate(snapshot(durableDoc), encodeStateAsUpdate(tabDoc)).Results (staging, bun 1.4.2, 4 shards x 12,500 trials x 40 steps each, two runs):
Conclusion: within the client, no path to Saved or onConfirmed without durable coverage was found. Tab, crash, IME, offline and refusal interleavings hold. The only liveness break is the P1.
P3: Saved waits on collaborators' typing (liveness, not safety)
Receipts.confirmedneeds every observed edit receipted, including a collaborator's packets that arrive after this tab's own check. While a peer types faster than one receipt round trip, this tab stays "Saving…", and the safe base does not advance. Its own edit was receipted long before.latency-fixed.ts, alternating): base shows Saved at 171–173 ms in 5/5 rounds. Head never shows Saved within 5 s in 5/5 rounds, although its own covering receipt arrived at 170 ms.R3-DEBOUNCEis flaky on this (1022 ms once, 173 ms on my rerun).R4-HELD-BUSYstays "saving".open.unsaved),data-saveand Vim:wsay Saving, and the base write is delayed during co-editing. Numbers from the HDD run are below.P3: one-off main-thread stall when a long offline session gets its receipt
Receipts.receipt()applies every retired edit's proof to the shadow doc one at a time. Microbenchmark (r5-micro/backlog.ts, real Receipts and Yjs): 2,000 offline edits → 61 ms; 10,000 → 293 ms; 30,000 → 272 ms for the one receipt after reconnect. Per-keystroke cost while offline stays under 0.15 ms p50. The shadow snapshot per remote packet is cheap: 0.09 ms p50 and 1.9 ms p95 on a 50k-edit note.P3 (design note): a size refusal can never be cleared
refusedpersists per note (meta and localStorage) and has no reset path. After a too-large paste, the device shows "Too large to save" for that note forever, even if the user deletes the paste and a later full resend is accepted. Edits after the paste really are stuck behind the refused struct, so this is defensible; still, there should be a user-visible way out (e.g. "keep a copy and reload from server").Not a finding:
large-nearmismatch9/10 runs of
review5-near-diagnostic.tsreportedpeer_equals_server:false. In every run the difference was the server-writtentitle: Bigfrontmatter line: the peer had it and the firstnotes.getdid not.peer_matches_fresh_api:trueevery time, so the copies converge. The cause is read timing in the probe, unrelated to receipts. The paste is stored once (server_starts:1), and A and B show Saved after it.Round-4 items
large-dos(8 rooms x 63 MiB on one socket) held 94 MiB RSS and dropped back to 31 MiB after 30 s. New check across connections (r5-dos/multi.ts, 8 sockets x 63 MiB):The total is bounded by the 256 MiB budget: sockets 4–7 got
left, and all expired by the timeout. Sequence and length mismatches cause a leave (code read,rooms.rs:318-327).large-toobigandlarge-restoreshow it; no Saved and no onConfirmed after the refusal.large-resend, where B's uplink is 5 s slow on a 20 MiB paste: A uploaded 931 bytes.group-*.log).kill_nine_never_loses_or_doubles: 50/50 with twonice -n 19CPU workers (staging, same head test binary, sha 7f296acc…; e.g. "30 kills, 479 confirmed appends, 29 in-flight appends retried"). The first reviewer's run with un-niced workers was also 50/50.P2 browser reproduction (real Chromium, chromium-390, head binary + head web build)
e2e/review5-signout.spec.ts: three tabs, with the uplink held so edits stay pending. Tabs 1 and 2 both open the "Sign out?" dialog. Tab 2 clicks Cancel; tab 1 is still asking. Tab 3's editor becomes editable again and takes new typing. Tab 1 then signs out anyway and the device is wiped, including that typing. Tab 1 never warned about it.Browser gates (local build slot, --workers=1, CALTERNAL_BIN = head debug build)
editor, signout, pwa-update, switching and big-paste on chromium-1440/390 and webkit-1440/390: 85 passed, 27 skipped, 0 failed (9.8 min). The skips are the existing project skips: pwa-update 13, switching 8, editor 6.
Perf VM HDD (root@10.69.69.63, one
flock -o /root/perf-vm.lockrun, data on /mnt/b/hdd-ext4 (rotational), release builds of origin/dev8b30062and2bbdffb, 6 rounds alternating base/head). Medians of per-round values:soloruns (2 base, 1 head) timed out waiting for a fresh Saved transition after the stop: a probe artifact, because the status was already Saved. Scripts:/home/kayg/codex-jobs/history-review5/client-perf/; raw JSON: perf VM/mnt/z4-hdd/review652-5/results2/.Verdict: DO NOT MERGE
Within the client, I found no way to show Saved or advance the base without durable coverage: grep, 15+5 repros, 100,000-trial SyncClient model, browser gates all clean. But:
too_many_requests, a history outage past 1024 in-flight changes) become a permanent, persisted, sibling-propagated "Could not save". It never clears after recovery. Reproduced on the real server, including a disk-full outage.Starting round 6 on branch issue/652-history-fix6, from origin/issue/652-history-fix5 at
2bbdffbc2e, merging origin/dev at8b30062e1c. Preserving the covering-server-receipt invariant. I will fix temporary failures, overlapping sign-out owners, own-edit receipt latency, incremental receipt processing, and clearing obsolete size refusals, then run the requested gates. Evidence stays in issue comments; no PR, merge, or deployment.Round 6 findings from code inspection:
Local gates are waiting in the required build-slot script because another test train is active. No slot guard is bypassed.
Regression evidence before and after fixes:
The focused receipt tests initially failed in three places: local receipt remained Saving after a later peer edit; removing a rejected paste never cleared Too large to save; a 10,000-edit receipt confirmed synchronously without yielding. After the first implementation all four focused recovery cases pass (2.21 s). The long receipt now yields between batches of at most 64 edits and a 4 ms time budget.
The original sign-out module fails five of six focused owner/expiry tests. The per-owner lease implementation passes all six. Each owner writes a separate expiring key, so concurrent begin operations cannot overwrite each other, and cancellation removes only its own key.
The real-SyncClient model's first 1,000 cases pass: 1,558 temporary room errors, 708 trials with transient join errors, 888 crashes, 788 liveness checks, zero missing durable coverage, zero covered-but-unsaved cases, and zero safety failures. Full 2 x 50,000 runs are queued through the required build-slot script.
The local heavy gates are still waiting behind the host test train. The perf VM lock is also occupied by unrelated jobs; measurement will wait for that lock. No shared jobs are stopped.
The extended model found an additional stale-refusal race while shrinking oversized content. A tab can hold the insertion and its later deletion behind IME across a reconnect. Resending each old packet separately rejects the obsolete insertion even though the final document is tiny; a late rejection can also arrive after the deletion was already applied.
The client now submits the complete current state after the gate drains rather than sending obsolete raw packets. A server size refusal remains visible while backing off and rejoining with current state; it clears only after the fresh submission has a covering receipt. Sibling/storage refusal hints also trigger independent revalidation, never confirmation by the hint. Note metadata and its synchronous refusal marker clear only on that real receipt.
Evidence: seed 652 trial 274 previously left two tabs refused/disconnected with an empty, 141-byte document already covered by durable history. The deterministic held-paste/reconnect regression and latest 1,000-case shrink model now pass: 908 independently covered liveness cases, 92 genuine remaining size-refusal cases, 1,669 temporary room failures, 842 crashes, zero safety failures or stuck Saved. The actual size-guard tests (reduced limit, real Yjs bytes) also pass for connected deletion, deletion after disconnect, and clearing persisted metadata/storage markers across reopen.
All requested heavy local gates remain queued behind the active host train. The HDD measurements are queued on the required perf VM lock behind unrelated work.
Final audit found and fixed one interaction between refusal clearing and peer typing: a refusal previously waited for the entire ledger to become empty. It now records the obligation horizon at refusal and clears only when fresh receipts retire all those obligations; newer peer edits continue to block the replay base but cannot extend the old error. The new targeted test failed before this change and passes afterward. Latest seed652 model: 1,000 cases, 908 durable-coverage liveness checks, 1,666 temporary room errors, 837 crashes, zero safety or liveness failures.
The host test train remains active, so functional gates are moving to isolated staging test directories/containers. Staging was 45% on root and 21% on its HDD before copying caches; tests will keep both below60%. These are temporary loopback test servers only; existing services are untouched. Local queued duplicates were cancelled using their own managed sessions. The two50,000 model runs and Rust/browser gates will use the same source snapshot there. HDD latency measurements remain queued on root@10.69.69.63 under /root/perf-vm.lock.
Real-server recovery evidence:
The permanent join-limit regression passes after opening128other rooms on one LiveSocket: the129th join fails once, retains typing during that failure, retries after a room closes, and reaches Saved. Refusal callbacks remain[null].
The permanent disk-full regression passes on a private64MiBtmpfs on staging. It fills66,469,888bytes, sends1200realSyncClient updates through the realLiveSocket, sees one retryable custom103 and one room close, and reports Not saved yet during the outage. After freeing space it reaches Saved with all1200updates and the post-recovery edit exactly once. Refusal callbacks remain[null]. The first container attempt could not mount a private tmpfs, so the actual filesystem test ran on the staging host; it unmounted and removed its own filesystem afterward. Existing services were untouched.
Current gate results: fmt pass; new actor tests2/2pass; clippy pass; editor34files/278tests pass; signout unit6/6pass; editor typecheck pass; svelte-check0errors/13existingwarnings. Full2x50,000models, workspace3x, crash50underload, browser4-project gates and HDD table are still running or queued.
Browser evidence: after two tabs start signing out, cancelling the newer dialog leaves the third tab read-only. Real keyboard input is rejected, the original text stays intact, and the remaining sign-out completes its wipe. The desktop Chromium cases pass with BroadcastChannel both enabled and disabled. The screenshot is from the rejected-typing step. Other browser projects are still running.
Editor unit gate output:
The first two workspace runs stopped at an unchanged authentication timing assertion:
The assertion requires the slowest median below 2.5 times the fastest. The test file is byte-identical to starting commit
2bbdffb(SHA256 9194b50c6c05a79096edcde88a8bf089d1ffbede12db3e5042a78b7926950de3). The third parallel workspace run also stopped at this assertion. My earlier progress reading mistook output from another authentication test binary; this paragraph corrects that report. I will retain these failures and obtain three full successful workspace executions, using one test thread for additional runs to reduce interference in this timing check. Every assertion remains in the runs.First full model run passed. The second seed is running. Exact output follows:
The second independent model run also passed. Both seeds completed 50,000 cases, totaling 100,000 cases and four million actions. There were 452,096 Saved checks, 548,754 whole-document onConfirmed checks, and 90,861 independently covered liveness checks. No safety or liveness failures occurred.
Second-run gate output (ANSI colors removed):
The crash test also completed all 50 runs under load with exit 0. Three serial workspace runs are next because all three parallel workspace runs hit the unchanged auth timing assertion already reported above.
The new concurrent sign-out regression passes all eight cases: desktop/mobile Chromium and WebKit, with BroadcastChannel enabled and disabled. Cancelling the newer dialog leaves the other owner frozen, actual keyboard input is rejected, and the remaining sign-out wipes only after the warning is accepted.
The mobile WebKit screenshot uses synthetic fixture text and shows no rejected suffix:
The initial mobile no-channel test fixture was corrected to reload on a mounted editor, then explicitly assert BroadcastChannel is absent. No product change was needed for that fixture failure.
Verbatim final output:
The first serial workspace run also failed the unchanged auth timing assertion (145412/418455/143339/442459/439343 ns medians). It is continuing with --no-fail-fast to collect all remaining results. We are diagnosing the environment without changing or skipping the assertion.
The unchanged auth timing assertion is sensitive to the test filesystem. The exact same compiled executable was probed with only TMPDIR changed, in RAM/HDD/RAM order. RAM passed twice; HDD failed. We will run three full workspace gates using a private bounded 2 GiB tmpfs for /tmp. No test source or assertion is changed or skipped.
auth-fs-ram-1792611876.log
auth-fs-hdd-1792611876.log
auth-fs-ram-1792611882.log
Completed server-side gates on the final product snapshot. cargo fmt --all -- --check, cargo clippy --workspace --all-targets -j4 -- -D warnings, the actor regression tests, the real SyncClient integration tests, both permanent real-server recovery reproductions, and all fifty crash runs under two owned CPU load workers exited 0. No source changed after these runs.
The initial container disk-full attempt failed before starting the test because a mount was unavailable. The host run below used its own bounded private tmpfs, passed, and unmounted it.
Verbatim gate output follows.
fmt.log
clippy.log
actor.log
real-syncclient.log
join-limit-host.log
disk-full-host.log
crash-50-under-load.log
crash-50.log
The broad browser gate found a timing race in the unchanged PWA test fixture. The waiting worker existed at trace time 219075.626 ms. The foreground event ran at 219088.086–219100.504 ms while the DOM still had data-save="saving". The subsequent reload wait began at 219103.443 ms and timed out. The product correctly refused to reload unsaved state.
The fixture waited only for ready/synced, which precedes its durability receipt. I added one assertion to open(): wait for data-save="saved" before testing the stated nothing-unsaved condition. Both the original fixture and PWA product code matched the starting branch. This diagnoses a pre-existing synchronization race; I have not claimed an empirical baseline rerun.
No PWA product behavior changed. A complete rerun of the five requested browser suites across all four projects is queued after the current run and the 60-repeat sign-out gate. The separate eight-case concurrent sign-out regression remains green.
Full workspace run 1/3 passed, exit 0. All assertions ran unchanged, including the auth timing regression. Command: cargo test --locked --workspace -j4 --quiet --no-fail-fast -- --test-threads=1. The container used its own bounded 2 GiB tmpfs at /tmp; this avoided the demonstrated HDD timing artifact.
Verbatim output:
Full workspace run 2/3 passed, exit 0. All assertions ran unchanged, including the auth timing regression. Command: cargo test --locked --workspace -j4 --quiet --no-fail-fast -- --test-threads=1. The container used its own bounded 2 GiB tmpfs at /tmp; this avoided the demonstrated HDD timing artifact.
Verbatim output:
Full workspace run 3/3 passed, exit 0. All assertions ran unchanged, including the auth timing regression. Command: cargo test --locked --workspace -j4 --quiet --no-fail-fast -- --test-threads=1. The container used its own bounded 2 GiB tmpfs at /tmp; this avoided the demonstrated HDD timing artifact.
Verbatim output:
Completed client gates on the final product snapshot. The full editor suite passed 34 files and 278 tests, the sign-out unit suite passed 6 tests, editor TypeScript passed, and svelte-check found zero errors. The web check reports 13 existing warnings. Both independent 50,000-case model outputs are already posted separately.
Verbatim output (ANSI colors removed):
editor-unit (exit 0)
signout-unit (exit 0)
editor-types-final (exit 0)
web-check (exit 0)
All three full workspace gates now pass; their verbatim output is in comments 63900–63902. Client gate output is in 63903. Both 50,000-case model runs, fifty crash runs under load, real-server recovery tests, formatting, clippy, and the eight concurrent sign-out browser cases pass. The 60-repeat mobile sign-out gate and corrected full browser rerun are still in progress.
The required perf VM gate is temporarily blocked on the shared /root/perf-vm.lock. Our owned wrapper PID is 1575358. The unrelated current holder is progressing through its HDD runs, with five earlier waiters still ahead of ours. We have not bypassed the lock or disturbed any other job. Both client variants and the common harness are prepared, including the exact reviewer 20 ms receipt delay, an isolated own edit while a peer keeps typing at 20 updates/s, and the 10,000-edit callback measurements. I will continue waiting and report actual measurements before finishing.
The requested 60-repeat mobile Chromium sign-out gate passed all 60 repetitions, exit 0. This is the reviewer’s exact targeted regression: signout.spec.ts, remote sign-out retains copies, chromium-390, --repeat-each=60 --workers=1. The corrected full four-project browser run has now started.
Verbatim output:
Additional P3 finding during final review: the real editor’s undo manager retains deleted Yjs content. A direct probe with real Y.UndoManager, insert 2,000 characters, stopCapturing, then delete all 2,000 yields {"text":"","bytes":2025,"undo":2}. Without the undo manager, Yjs garbage-collects that content. The existing pure-Yjs size tests therefore missed a real editor condition: a removed oversized paste can still make a full retry packet too large.
I am adding a permanent undo-manager regression first, then compacting only oversized wire snapshots through a separate Yjs document. That preserves the live document, edit identities, deletions and undo stack; confirmation will still require a covering receipt. Only our queued perf wrapper PID1575358 was stopped after verifying it had no children or started run, so stale code cannot be benchmarked. No unrelated processes were touched. Relevant client/model/browser gates will rerun after the fix.
The undo-retained paste regression is fixed. An oversized current-state packet now falls back to a separate garbage-collected Yjs wire document. Normal-size packets keep their existing path. The live document and undo stack are untouched, original edit identities/deletions remain covered, and the receipt ledger records the actual compacted packet.
A direct real-Yjs probe showed liveBytes=2025, wireBytes=25, covers=true; undo still restored all 2,000 characters in the live document while the wire copy remained empty.
The permanent focused tests first failed on old code (three failures/two passes), then all five passed on client SHA256 5ef7e0576c1394db55d5778f09d4e2c7b5a8430e4c2484d939eb62919c6cfe72. The new cases cover connected and dropped transports, a fresh receipt before clearing, retained undo/redo stacks, restored paste becoming refused again, and persisted marker clearing through reopen.
Both 50,000-case model runs, the full client suite, real SyncClient/recovery tests, and a new browser build with all browser gates are rerunning. Rust source is unchanged, so the three full workspace passes, clippy, formatting and fifty Rust crash runs remain applicable. The perf source is being updated before requeueing.
Verbatim focused green output:
The final undo-preserving client snapshot also passes the real SyncClient bridge and both actual server recovery reproductions. All three commands exited 0. The disk-full test again used only its own bounded private tmpfs and cleaned up its mount. No permanent refusal was recorded for either temporary failure.
Verbatim output:
real-syncclient-undo-final (exit 0)
join-limit-undo-final (exit 0)
disk-full-undo-final (exit 0)
The preliminary staging callback diagnostic completed six runs after the browser gate finished, using the final client. It measured 10,000 offline edits in the receipt authority and through the real SyncClient. Every measured receipt/drain turn stayed below 16 ms: worst authority turn 8.376 ms; worst SyncClient receipt/timer turn 0.885 ms. The worst complete packet handler was 12.060 ms. These are staging diagnostics, not the required perf VM results.
The official perf VM job is requeued under /root/perf-vm.lock as owned wrapper PID1584410. Final source archive SHA256 is 8f266c014498c73b68dc9f8950bdd1e7c5f8f67a9e1b0bab844e46695ea8d3fd, including client 5ef7e057…c6cfe72, current tests and ADR. No earlier job was disturbed.
Verbatim diagnostic output:
Final client gates after the undo-retained paste fix: the complete editor suite passes 280 tests in 34 files; editor types, six sign-out unit tests, action types and svelte-check all pass. The first 50,000-case model rerun also passes with no safety or liveness failures. The second seed is running. Product client SHA256: 5ef7e0576c1394db55d5778f09d4e2c7b5a8430e4c2484d939eb62919c6cfe72.
Verbatim output (ANSI colors removed):
editor-unit-undo-final (exit 0)
editor-types-undo-final (exit 0)
signout-unit-undo-final (exit 0)
web-check-undo-final (exit 0)
seed1-50000-undo-final (exit 0)
Both independent model reruns now pass on the final undo-preserving client: 100,000 cases and four million actions. There were 161,196 temporary room errors, 83,206 crashes, 90,861 independently durable-covered liveness trials, 452,092 Saved transition checks, and 548,779 whole-document onConfirmed checks. No safety, missing-coverage or stuck-Saved failures occurred. The independent oracles are unchanged. All final editor/type/sign-out/web gates also passed, as posted in comment 63938.
Verbatim second model output (ANSI colors removed):
The fresh browser build containing the undo-preserving fix passes the eight concurrent sign-out cases and the five requested broad suites across all four projects. All runnable cases pass: 8/8 new regressions and 85 broad tests.
The 27 existing broad skips are PWA project selection (12), the signed-out PWA WebKit routing fixme (1), phone-only list/note layout exclusions for switching (8), phone margin controls (2), unavailable WebKit Layout Instability API (2), and Chromium-only IME tooling (2). All four requested projects were selected; no new skip was added. The final 60-repeat mobile sign-out run is now in progress.
Verbatim output:
pw-round6-signout-undo (exit 0)
pw-broad-undo (exit 0)
The final browser build also passes all 60 repetitions of the targeted mobile Chromium sign-out regression, exit 0. No cases were skipped in this stress run. The new concurrent-sign-out cases and all broad browser suites already passed on the same build (comment 63945).
All functional gates are green on committed head
d1b8c08444. The worktree is clean. The branch is not pushed yet: the required locked perf VM table remains queued under owned PID1584410. We will report its actual HDD and peer-typing measurements before finishing.Verbatim stress output:
The paired staging memory probe also matches the base for the peer-typing reproduction. This is a preliminary diagnostic while the official perf VM job waits for the required lock, not a substitute for its HDD table. Common harness: 300 KB note, peer typing at 20 updates/s, 20 ms receipt delay, one isolated own edit with a five-second deadline, then forty own edits.
The isolated edit reached Saved in 170.577 ms on base and 171.201 ms on the fix; each received four peer packets while waiting. Both had zero missed Saved transitions over the forty later own edits. Saved median was 170.302 ms versus 170.547 ms.
Verbatim base/head output:
The official job remains queued under /root/perf-vm.lock as owned PID1584410. The current holder is finishing its storage-floor checks; we have not disturbed it or earlier waiters.
All functional gates are complete on clean committed head
d1b8c08444. Final client/model output is in comments 63938 and 63943; final browser output is in 63945 and 63956. The branch is still unpushed while the required performance VM gate waits.The queue has advanced and our owned wrapper PID1584410 is now next after the current holder. We have neither bypassed /root/perf-vm.lock nor disturbed another job. No official measurements have started yet.
The baseline provenance audit is also complete: all 327 tracked Rust/build files match exact
8b30062. The common server benchmark differs only in the sender type required by each version’s API; its scenario, timing and output code is identical. Both clients use the same harness and pinned dependencies.Verbatim baseline audit:
The required perf VM gate is still blocked on /root/perf-vm.lock. Our owned wrapper PID1584410 is healthy and next in line. The final earlier holder finished its sweeps and several checks, then chained another benchmark round without releasing the lock. There is no reliable finish time. I have not disturbed that job, bypassed the lock, or treated the staging diagnostics as the required HDD result.
All functional work remains committed and clean at
d1b8c08444. All requested functional/model/browser gates pass, with verbatim output already posted. The official VM table is the sole pending gate, and the branch remains unpushed while I continue waiting.The required perf VM gate has now acquired /root/perf-vm.lock exclusively at 2026-10-22 00:17:24 CEST. Our runner PID is 1686814, under owned wrapper PID1584410. The earlier jobs finished without intervention.
The release build is starting from the final source archive 8f266c014498c73b68dc9f8950bdd1e7c5f8f67a9e1b0bab844e46695ea8d3fd, matching committed head
d1b8c08444. Baseline is exact8b30062. The run first measures six 10,000-edit receipt cases, then six alternating base/head pairs covering server latency, real clients, continuous peer typing on HDD, and the matching in-memory peer case. I will check all 90 expected JSON outputs, errors and callback durations before finishing.Official perf VM finding on head
d1b8c08444: the first of six 10,000-edit receipt probes exceeded the 16 ms callback budget in the standalone receipt authority: 21.903 ms. Its initial receipt call took 7.932 ms. The other five authority runs peaked at 6.597, 12.279, 14.247, 9.565 and 5.672 ms. All six actual SyncClient receipt and continuation measurements were below 16 ms, worst 5.528 ms. These are elapsed callback durations, excluding queue wait; the raw harness field names still say cpu_ms. The unchanged HDD comparison continues under the same exclusive VM lock. I am investigating the standalone failure before accepting this gate.Raw output:
Receipt budget investigation on staging, unchanged source
d1b8c08444. Six fresh-process runs of the byte-identical authority all used at most 4.018 ms of main-thread CPU per callback. One reproduced the elapsed-time failure: 17.564 ms wall time, 3.497 ms main-thread CPU, and 11.698 ms runnable-queue wait. This particular outlier is largely scheduling delay. It supports, but does not prove, the same explanation for the original uninstrumented perf-VM outlier.An external candidate that merged 32 proofs per continuation, with a 2 ms gathering budget, preserved ten semantic checks but increased median total drain time from 235.229 ms to 394.808 ms. I am keeping the product code unchanged based on these data. The official VM will run six fresh processes with the same external CPU and scheduler counters after its unchanged 90-measurement table finishes. Neither original failures nor raw outputs are replaced.
Verbatim diagnostic summary:
Official locked HDD table is halfway through its six alternating base/head pairs. All completed scenarios have finished without an application error. In the first three pairs the 300 KB note, with a peer still typing at 20 updates per second, reached Saved for the isolated local edit in every run.
HDD isolated Saved milliseconds: base [339.589, 462.053, 275.734], fix6 [179.379, 172.806, 153.113]. Peer packets received during those waits: base [5, 12, 7], fix6 [4, 3, 3].
In-memory isolated Saved milliseconds, with a 20 ms receipt delay: base [171.139, 170.805, 171.122], fix6 [178.295, 172.170, 173.072]. Peer packets: base [4, 4, 4], fix6 [3, 4, 3].
The separate bulk-edit probe had 250 ms deadline misses per 40 edits: HDD base [0, 0, 0], fix6 [1, 2, 0]; memory [0, 0, 0] for both. These counts will be reported individually and in total, alongside the full table; a zero median must not hide a missed deadline. The remaining pairs are still running. The original standalone 21.903 ms callback wall-time failure remains preserved in comment 64242.
Final source audit: head
d1b8c08444includes the starting dev SHA8b30062e1c. The requested initial merge was already up to date. The shared remote-tracking origin/dev reference advanced to9ed9b9a5e8during this long test run (reflog: fetch at 2026-10-21 22:06:51 +0200). I am preserving the approved starting base and measured source instead of introducing later unrelated changes after verification. No main or dev branch is being pushed. All 20 changed files match the perf snapshot, git diff --check passes, and the worktree is clean.The required perf VM table is complete on head
d1b8c08444. All 90 original measurements are present, parseable, and have no application errors. The process runner exited 0. The separate strict callback-budget validator exited 1 because of the original standalone 21.903 ms callback; this failure is preserved. This is not an all-green timing result.Perf VM HDD results: baseline
8b30062e1c14966e05e14ea67f8feb65e6e355c4versus fix6d1b8c08444c54b1067d95516bad62cffdd1bd513(source archive SHA-2568f266c014498c73b68dc9f8950bdd1e7c5f8f67a9e1b0bab844e46695ea8d3fd). Six alternating base/head pairs under exclusive/root/perf-vm.lock; data on/mnt/b/hdd-ext4/history652-fix6. Values are medians of per-run percentiles/counts, not pooled percentiles. Both client versions use the same harness and pinned dependencies. The final-Saved probe reports zero when the last edit was already Saved at typing stop.Isolated edit Saved deadlines (peer remains active):
Individual peer-typing runs (to preserve deadline misses instead of hiding them in a median):
10,000 offline edits, receipt processing; elapsed callback duration from an external timer wrapper (queue wait excluded; includes any OS descheduling):
Raw JSON files: 90/90 expected. Six runs are expected for every version/scenario.
Errors: none
Verbatim validator output (exit 1):
Verbatim runner status:
Follow-up timing finding, unchanged product source, six fresh processes under the same exclusive perf VM lock after all 90 original measurements finished. All six reached confirmed state and exited 0. The original files were hashed before and after and stayed unchanged. The lock is now released.
Actual SyncClient receipt handlers and continuation callbacks peaked at 11.742 ms elapsed and 4.944 ms main-thread CPU. The standalone receipt authority peaked at 18.168 ms elapsed and 10.737 ms main-thread CPU, with those maxima occurring in different callbacks. The 18.168 ms callback itself used 5.116 ms main CPU and only 0.031 ms measured runnable wait, so these counters do not fully attribute its elapsed time. The original 21.903 ms callback had no CPU counters and cannot be attributed retrospectively.
Two separate non-receipt sync-packet handlers exceeded 16 ms of main-thread CPU: 17.340 ms and 21.144 ms. They were explicitly labelled packet-handler, distinct from the receipt-handler measurements. They are retained below as broader reconnection timing limits. I am not claiming every callback or frame stayed below 16 ms.
The requested incremental receipt drain is in place. These results do not justify the tested 32-entry merged-proof candidate, which increased total drain latency by 68% on staging. I have preserved the tested product source and am reporting the remaining strict timing limits rather than hiding them.
Verbatim diagnostic summary:
Verbatim diagnostic process output:
Verbatim original perf output, part 1/3, head
d1b8c08444. All 90 original JSON outputs are included across these comments, including the failed wall-time budget.cl-base-collab-r1.json
cl-base-collab-r2.json
cl-base-collab-r3.json
cl-base-collab-r4.json
cl-base-collab-r5.json
cl-base-collab-r6.json
cl-base-lag-r1.json
cl-base-lag-r2.json
cl-base-lag-r3.json
cl-base-lag-r4.json
cl-base-lag-r5.json
cl-base-lag-r6.json
cl-base-single-r1.json
cl-base-single-r2.json
cl-base-single-r3.json
cl-base-single-r4.json
cl-base-single-r5.json
cl-base-single-r6.json
cl-base-solo-r1.json
cl-base-solo-r2.json
cl-base-solo-r3.json
cl-base-solo-r4.json
cl-base-solo-r5.json
cl-base-solo-r6.json
cl-head-collab-r1.json
cl-head-collab-r2.json
cl-head-collab-r3.json
cl-head-collab-r4.json
cl-head-collab-r5.json
cl-head-collab-r6.json
cl-head-lag-r1.json
cl-head-lag-r2.json
cl-head-lag-r3.json
cl-head-lag-r4.json
cl-head-lag-r5.json
cl-head-lag-r6.json
cl-head-single-r1.json
cl-head-single-r2.json
cl-head-single-r3.json
cl-head-single-r4.json
cl-head-single-r5.json
cl-head-single-r6.json
cl-head-solo-r1.json
cl-head-solo-r2.json
cl-head-solo-r3.json
cl-head-solo-r4.json
cl-head-solo-r5.json
cl-head-solo-r6.json
memory-base-r1.json
memory-base-r2.json
memory-base-r3.json
memory-base-r4.json
memory-base-r5.json
memory-base-r6.json
memory-head-r1.json
memory-head-r2.json
memory-head-r3.json
memory-head-r4.json
memory-head-r5.json
memory-head-r6.json
receipt-r1.json
receipt-r2.json
receipt-r3.json
receipt-r4.json
receipt-r5.json
receipt-r6.json
srv-base-hdd60-r1.json
srv-base-hdd60-r2.json
srv-base-hdd60-r3.json
srv-base-hdd60-r4.json
srv-base-hdd60-r5.json
srv-base-hdd60-r6.json
srv-base-single-r1.json
srv-base-single-r2.json
Verbatim original perf output, part 2/3, head
d1b8c08444. All 90 original JSON outputs are included across these comments, including the failed wall-time budget.srv-base-single-r3.json
srv-base-single-r4.json
srv-base-single-r5.json
srv-base-single-r6.json
srv-head-hdd60-r1.json
srv-head-hdd60-r2.json
srv-head-hdd60-r3.json
srv-head-hdd60-r4.json
srv-head-hdd60-r5.json
srv-head-hdd60-r6.json
srv-head-single-r1.json
Verbatim original perf output, part 3/3, head
d1b8c08444. All 90 original JSON outputs are included across these comments, including the failed wall-time budget.srv-head-single-r2.json
srv-head-single-r3.json
srv-head-single-r4.json
srv-head-single-r5.json
srv-head-single-r6.json
Final per-run latency audit found one additional deadline miss that the median row does not show: fix6 missed 1 of 60 own-edit Saved deadlines of 2.5 seconds in the small-note peer-at-8/s case, versus 0 of 60 for base. It occurred in head round 1. All six isolated own-edit checks for that scenario did reach Saved within five seconds while the peer continued. All 24 isolated large-note HDD and memory comparisons also passed their five-second deadline.
The separate large-note HDD bulk probe missed 5 of 240 deadlines of 250 ms on fix6, versus 0 of 240 for base. Memory missed 0 of 240 for both. These tail results mean I am not claiming identical latency to base in every run. The complete raw outputs already posted retain every count.
Verbatim small-note round-1 output:
Pushed issue/652-history-fix6. Head:
d1b8c08444. The remote branch advertises exactly that SHA and the worktree is clean. No PR was opened. The issue remains open.Temporary join and room failures now retry with backoff and a fresh room join instead of persisting a refusal. Permanent size refusals clear only after a fitting current-state submission has a covering receipt, including removal of an undo-retained paste. Sign-out freezes have separate owner leases. Saved waits for this device’s receipts; the safe replay base still waits for every observed edit. Receipt retirement yields after bounded batches.
All functional gates passed: fmt, clippy, three workspace runs (832 passed and four existing ignored each), fifty crash runs under load, real SyncClient bridge tests, both permanent real-server recovery reproductions, editor unit tests and types, sign-out unit tests, two 50,000-case model runs, svelte-check, the requested four-project browser suites, concurrent-sign-out cases, and sixty mobile Chromium sign-out repetitions. The 100,000 model cases had zero safety failures, zero missing coverage, and zero covered-but-unsaved failures. The browser suites retained 27 existing skips; svelte-check retained 13 warnings.
Performance acceptance is qualified. All isolated peer-typing Saved checks passed their five-second deadline; median large-note HDD time was 163.386 ms for fix6 versus 320.750 ms for base, and memory was 172.945 versus 171.131 ms. The strict callback wall-time validator still fails on the standalone 21.903 ms sample. Follow-up actual SyncClient receipt and timer callbacks stayed below 16 ms, but separate non-receipt sync-packet callbacks reached 17.340 and 21.144 ms of main-thread CPU. The HDD bulk probe also retained five of 240 misses of 250 ms, and the small-note collaborator probe retained one of sixty misses of 2.5 seconds. I am not claiming every frame stayed below 16 ms or identical tail latency to base. All of these limits and the unproven cause of the original wall-time outlier are reported in the evidence.
The starting dev SHA was
8b30062e1cand its initial merge was already up to date. The shared origin/dev reference advanced during testing; the tested starting base was preserved, as recorded in comment 64306.Full gate output is posted verbatim in these comments:
Verbatim final functional gate summary excerpts:
model/remote/editor-unit-undo-final.log
model/remote/editor-types-undo-final.log
model/remote/signout-unit-undo-final.log
model/remote/web-check-undo-final.log
model/remote/seed1-50000-undo-final.log
model/remote/seed652-50000-undo-final.log
browser-evidence/pw-broad-undo.log
browser-evidence/pw-round6-signout-undo.log
browser-evidence/pw-signout60-undo.log
Verbatim final audit output (the strict perf validator remains exit 1):
Verbatim push and remote verification output:
Independent review of round 6 (head
d1b8c08). Verdict: do not merge yet.Full findings with logs, repro commands and verbatim gate output:
/home/kayg/codex-jobs/history-review6/findings.md(on the host).What holds. I couldn't make Saved show early. I tried the author's model, my own variant of it (3,300 trials, with undo/redo and the client size limit set to match the model server, so the undo-compaction path actually runs), targeted tests and the real Rust server. Temporary room and join errors no longer turn into a lasting refusal. Undoing a refused paste while offline gets back to Saved on the real server, with server text matching the client. Sign-out freezes now have one lease per tab. Gates: fmt ok, clippy ok, workspace 832 passed / 0 failed / 4 ignored, notes_crash 20 of 20 ok, editor vitest ok, tsc ok, wipe test 6 of 6, svelte-check 0 errors / 13 warnings.
P1, new in round 6: typing in a note that still holds a too-large paste freezes the tab. Each save check, including the one a collaborator's packet triggers, re-encodes and re-compacts the whole document of more than 64 MiB on the main thread. Each stall is 0.6–1.1 s, about 12 s blocked over 4 s of typing, and it reproduces on the real server. Round 5 and dev have no stall. The cause is
retryChangedRefusal()running before everysendCheck()→currentStatePacket().P2: while any refusal is waiting for its receipt, every save check uploads the whole note again. 20 keystrokes sent about 20 full copies.
P3: the receipt drain is a chain of
setTimeoutcalls, which background tabs throttle, so a large offline backlog takes minutes to show Saved. One drain step still takes about 20–28 ms, which is over the 16 ms target.Perf question: the 17–21 ms sync-packet callbacks come from the step-1 handler, and they were already there before this round. Round 5 measured 16.8 ms median and 60 ms max; dev measured 11–20 ms. So they are not a round-6 regression. Round 6 cut receipt handling from about 174 ms to 1.2 ms.
Starting round 7 on issue/652-history-fix6 at
d1b8c08444. Fetched origin/dev and started the required merge (one signout.spec.ts conflict, being resolved retaining both guarantees). Work is limited to refusal and receipt performance plus regression coverage. CLAUDE.md is absent from this worktree and its parents; following the job instructions. No review findings files will be opened. No PR, merge into dev/main, or deployment.The new regression tests reproduce all three performance failures on the exact
d1b8c08editor source, copied with git archive to a separate test directory. Tests ran on staging in /root/issue652-r7/before with the same dependencies as this worktree. No product code from the merged branch was used for this before measurement. Staging disk use is 48%.Verbatim measurement output:
The 3.2 KB refusal-pending test permits one full copy plus ordinary edit bytes.
d1b8c08sent twenty copies. Both local typing and small collaborator packets next to the 65 MiB refused paste took over 400 ms per callback. The 10,000-edit test asserts MessageChannel scheduling, completes every queued callback, and checks Saved and the 16 ms budget; the old implementation scheduled a timer instead, so that assertion fails. Initial paste construction is outside the subsequent-typing measurement.The required dev merge is b4399fc. Its conflict resolution preserves the shared sign-out fixture and owner-lease tests, moves dev's TLS fixture changes into that shared fixture, and retains dev's old-name-cookie regression. No review findings files were read. Local heavy gates are queued through the required slot wrapper behind the active train; staging tests run directly over SSH.
The corrected small server/client limit model exposed two refusal-recovery edge cases during implementation. A late oversized sibling packet can already be deleted in the current document; caching its size as the current state's size would wrongly suppress recovery. Only actual complete submissions or a live-text lower bound now establish that cache. Also, a full retry excludes edits still held by IME. Such an edit, once applied, now gets its own ordinary submission and subsequent receipt after the full retry is outstanding. It cannot retire against the earlier receipt. These changes preserve the round-6 late-packet and IME guarantees while avoiding repeated full uploads.
The extended model uses the same 1500-byte framed-message limit on client and server, real UndoManager undo/redo, sign-out/disconnect during backoff, and a full-state byte budget based on observed refusals, deletion changes, and connections. The dedicated 20-keystroke test enforces the stricter single-copy budget with one stable refusal.
Verbatim latest model output:
The large-proof regression also fails on the exact
d1b8c08source after waiting for all drain callbacks, so it measures callback time rather than requiring immediate Saved:Receipt coverage now retains struct ranges, prerequisites, and deletion sets without rebuilding note strings. Dedicated tests compare its coverage with a real Yjs shadow under missing parents, reordered updates, undo, redo, and deletions. Large retry serialization uses a worker wire copy, independently garbage-collected from the live undo history. Worker replies are checked against connection, deletion version, and refusal generation before granting submission; receipts remain the only durability authority.
The real browser worker path is now exercised as well. On staging, Chromium at both requested widths typed twenty keys and applied twenty independent collaborator packets next to a refused 65 MiB paste, then removed the paste while its UndoManager retained it. The worker encoded a fitting retry; refusal stayed visible until that retry's receipt. No measured input, applied-packet, receipt, or worker-result callback exceeded 16 ms in this run.
Verbatim output:
The optional pre-existing step-1 path is only changed for documents that already have a large refusal worker: those replies also encode there. The normal step-1 path remains synchronous. I am not claiming a universal sub-16 ms result for ordinary sync-packet handlers.
An early direct-ledger backlog probe still measured a 19.8 ms callback while replaying redundant original proofs. The production reconnect path already replaces those proofs with one complete-state proof. The permanent backlog test now follows that production path, and the separate large step-2 proof test retains its own strict callback budget. The drain also yields at a 2 ms work budget. Final measurements and full gate output will follow; the two long model runs are in progress. The local train still owns the build priority, so all local heavy commands remain queued through build-slot.sh.
Round 7 (performance): head
7439403onissue/652-history-fix7Commits on top of
7152094:aa69b63(fix),ce6d83c(model fidelity),43bc7d4(perf tests: best of 3 rounds),7439403(held pre-reconnect packet resent alone).What changed from the unfinished Codex worktree: I reviewed its uncommitted edits and kept only the content-free coverage (
sync/coverage.ts) and MessageChannel drain ideas. I dropped the worker mirror (state.worker.ts), the persistent compaction doc and the deletes counter. Instead there is a size lower bound, with no second copy of the note in memory.awaitingRetry= some applied edit still refused). Later edits travel as ordinary updates. A refused or pre-reconnect packet held behind IME is resent on its own once applied, instead of another full copy.Y.Doccopy of the note is gone.Before / after (reviewer scripts; before =
d1b8c08worktree, same host, load ~15)Offline backlog of 10,000 edits (offline-perf-timers plus MessageChannel task timing):
Real Rust server (real-server.ts, debug build of this head):
(review on
d1b8c08:stallsOver50msWhileTyping:[770,1076,1058,875,823,741,643,697,638])New tests: fail on
d1b8c08(editor source copied with git archive), pass on headtest/refusal-performance.test.tson the head:on
d1b8c08: all 7 fail (R7-BYTES … "bytes":66939,R7-OVERSIZE … "localMax":1232.5ascii / 2026.9 unicode,R7-RECONNECT 1022 ms, deleting the paste sent 5 full copies,R7-LARGE-PROOF 38.0 ms,R7-DRAIN posts 0, 157 zero-delay timers).The browser spec
e2e/refusal-performance.spec.tspasses on all 4 projects:Still open, not hidden: undoing a 65 MiB paste that UndoManager retains triggers one compaction for the retry:
retryMs453–1399 ms in the browser, about 300 ms in bun. It runs once per change that could make the state fit, never per key. Next step if wanted: a worker, or a custom encoder that writes deleted items as GC.Model (client limit = server limit 1500 B, UndoManager undo/redo, sign-out during backoff, byte budget, new "fits ⇒ Saved" oracle)
The same model on
d1b8c08fails the byte budget (seed 1, 2,000 trials: 136 failures; seed 652, 50k: 3,759).During the first 50k runs, the model showed a "Saved without durable coverage" at seed 652, trial 34068. Its server never journaled an input that was parked for a missing prerequisite, yet acknowledged it; then a crash lost it. The real room does journal parked inputs (crates/notes
pipeline.rs apply_typed), and the model now does too (ce6d83c). Byte-budget false positives from relayed packets were also excluded. One genuine double full copy (a held pre-reconnect packet) was fixed in7439403.Gates (verbatim)
Rust gates, svelte-check and wipe ran on
aa69b63. The later commits touch onlypackages/editorTypeScript, and vitest and tsc were re-run on7439403.Playwright: 24 failures, all already there before this round. Every one also fails with d1b8c08's
client.ts/receipts.tsswapped into this same tree (logspw-base-signout.log,pw-base-webkit.log):review4-signout.spec.ts:230×16 (4 variants × 4 projects). It expects a refusal to survive "a later genuine upload and receipt". That contradicts the round-6 contract (a covering receipt for a fitting state clears it), so the test needs updating.signout.spec.ts:21×4:oldCookieundefined after the dev merge.review4-signout.spec.ts:62andsignout.spec.ts:141on WebKit ×4: "Unacceptable TLS certificate" or the page closed.All other selected specs pass on chromium-390/1440 and webkit-390/1440: editor, switching, pwa-update, big-paste, review6-signout, refusal-performance.
Round 7, browser gate: head
1208bfbonissue/652-history-fix7New commit
1208bfbchanges tests only (apps/web/e2e); there is no product change since7439403. Every run below used the train's environment (the same env vars ase2etrain-xl.sh,cd apps/web,bunx playwright test --workers 1 <files> --project …).storage_quota). The oldstorage_failedis temporary, and by contract it retries quietly without "Could not save".16 passed (5.7m)on all 4 projects.02338cfwith the train env:20 passed (6.4m)/playwright rc=0. On the branch, the test looked for the removedcalternal_sessioncookie. It now looks for__Host-calternal_session, as dev's spec does. No code change was needed.ignoreHTTPSErrors, which caused "Unacceptable TLS certificate". This spec exists only on the branch, so it can't be run on dev.offline(false)ran on the closed page. On dev it passes (inside the 20 above).1208bfb, all 4 projects:The one failure was already there before this round, as a WebKit flake. Repeated 3× on webkit-390:
['1 failed', '11 passed (4.7m)']client.ts/receipts.tsin the same tree:['3 failed', '9 passed (7.7m)']. Same error,Saved fixture unexpectedly requires discard confirmation, with the daily noteday-2026-10-22showingheldAgeMs13–16 s. That is a collaborator change still waiting for its receipt when sign-out starts (host load average about 21). Not caused by this round; it needs its own investigation.Still open, as documented: undoing a 65 MiB paste that UndoManager retains costs one compaction of 0.5–1.4 s for the retry.
Independent review of round 7 (head
1208bfb, product code7439403). Verdict: do not merge yet. One real-server liveness bug remains.Full findings, repro scripts and verbatim gate output are on the host:
/home/kayg/codex-jobs/history-review7/findings.md.Fixed as claimed
Held up under probing
apply_typed.P1 N1 (also present in round 6; I missed it then)
resyncand parks every later save check inheld_check. The client's full-state retry goes out as a sync Update, and only the SyncStep2 path callsresynced. The check is never answered.KEYS=1 bun /home/kayg/codex-jobs/history-review7/scripts/real-server-online.ts. With KEYS=0 it passes. Offline undo also passes.resyncedwhen an Update leaves nothing missing. Add a real-server regression test.P3 N2. The first deletion after a multi-byte paste that is too large still triggers one full encode: 570 ms at about 72 MB of CJK text.
insertedBytesstops counting at the limit; counting the whole paste fixes it.Perf question. The step-1 handler takes 22–30 ms with a 10k backlog. It was the same in rounds 5 and 6, so this is not a regression.
Review 7 findings: head
325ecc3onissue/652-history-fix7Commits since
1208bfb:8558d78,9418277,325ecc3.N1 (P1): fixed in the client; the room's rule is unchanged
Every complete-state submission is now a sync step 2. The undo retry is
encodeStep2(doc, emptySV), or the compacted copy.Why not let the room release held checks after an update that leaves nothing missing: that would break the room's guarantee. Updates the room refused for a gap are discarded, not parked. An ordinary update that happens to leave nothing missing says nothing about those discarded packets, while the client counts them as sent. Releasing the held check would then retire them: Saved without the text. A step 2 is the client's answer "here is everything you lack", so the room keeps "only a step 2 that fills every gap releases held checks". The client now honours that.
Reviewer repro on the real server, head:
The class: test rooms now follow the real room, which found two more pre-existing bugs
test-server/resync.tsimplements crates/notes' gap rule (follows_onviaY.parseUpdateMeta,has_missing, resync with a single held check whose queued answers are dropped, released only by a step 2). Both the JS testRoomand the model's server use it.performance.now, so the async MessageChannel drain interleaves with everything else in every trial; one race had only shown up on a loaded host.d1b8c08and1208bfb, both are now fixed, and both are Saved-early cases, not just liveness:9418277: a sibling edit forwarded while it was still behind IME is refused for a gap. The room asks for a resend, and the step 2 answer can only hold applied state. That answer satisfies the room, and the released check retired the forwarded edit. Now a resend request marks edits still behind IME unsubmitted, and they travel again once applied.325ecc3: the same race when the edit is forwarded while the room is already waiting, so it sends no new request. Now, while a resend is owed, an edit's own packet only counts if it is applied here. The step 2 sent before the next check carries it; otherwise it travels again once applied.1208bfband passing on the head:test/resync.test.ts: keys after a refused paste, then undo online or offline; the forwarded-edit case.1208bfb, 2,000 trials:coveredButUnsaved39 andfitsButNotSavedfailures.integration/real-server.test.ts, real binary: 3 of 9 fail on1208bfb(both "type 1/10 keys, undo online" cases and the two-device case).Real-server suite (new, in CI)
packages/editor/integration/real-server.test.tsruns the real SyncClient and LiveSocket against thecalternalbinary. It covers a 65 MiB paste with 0, 1 or 10 keys, then undo online or offline; a reconnect while oversized, then delete; a 2,000-edit offline backlog; and two devices. CI's web job runs it after the binary wait step (bun test ./packages/editor/integration/real-server.test.ts). On the head:N2 (P3): fixed
The bound counts the paste's full UTF-8 size. A new test spies on the full-state encode: the head makes 0 encodes,
1208bfbmakes 1 (rounds1919 ms the first time). Reviewer CJK repro on the head:2×50k model (faithful server, forced drain yields)
Perf re-check (reviewer scripts, head vs
d1b8c08)The 10k offline backlog on the head: 156 MessageChannel steps, longest under 1 ms; the step-1 handler is unchanged (pre-existing).
Gates (verbatim)
Browser: 1 failure, already flaky before this round. It is the WebKit flake from my previous comment:
review4-signout.spec.ts:131on webkit-390. The error is "Saved fixture unexpectedly requires discard confirmation" because the daily note has a collaborator change waiting more than 2 s for its receipt (host load average about 23). Earlier evidence: repeated 3× with d1b8c08's sync code,3 failed, 9 passed; head1 failed, 11 passed. Everything else passes on all four projects.Flakes seen during runs and confirmed by re-runs:
crates/auth/tests/reliability_review.rscounter_concurrent_mutations_drift_and_restart: one failure; 3/3 passes on re-run, and no crates changed since7152094.tree-cost.test.ts: timing under load; passes on re-run.Still open, as documented: undoing a 65 MiB paste that UndoManager retains costs one 0.5–1.4 s compaction for the retry.
Independent review of round 8 (head
325ecc3). Verdict: merge, as far as history and "Saved" correctness go. One P3 note below.Full findings:
/home/kayg/codex-jobs/history-review8/findings.md(on the host). The Rust code is unchanged since1208bfb, so the round-7 Rust gates still apply: fmt and clippy ok, workspace 893 passed / 0 failed / 5 ignored, notes_crash 20 of 20.Fixed, checked on the real binary
integration/real-server.test.tspasses 9 of 9 on325ecc3in two runs. On1208bfbit is 6 pass / 3 fail (the online-undo and two-device cases), matching the claim.Test doubles vs the real room:
resync.ts, the test room and the model server match crates/notes on every gap and held-check rule:follows_onvsfollowsOn;The one difference: JS
hasMissingsees Yjs's lazily retried pending list, so the doubles ask for resends somewhat more often than the real room. That makes them stricter, not more lenient. Discarding a gap update cannot lose a typed edit: edits are kept until a receipt, and edits still behind IME are unsubmitted or marked for resend and sent again once applied.P3 R8-1:
case 'saved': this.owed = nullassumes any answer ends the room's wait. In acks.rs, checks queued before the gap are still released whileresyncis true. The effect only matters while no step 2 has been sent, which happens only when the note is still too large. In that window, a sibling edit sent before it is applied here could lose its resend guard. I couldn't build a reachable sequence that loses or wrongly confirms an edit, and the model (which releases those checks) is clean. Suggested: clearowedonly on an answer to a check sent after the answering step 2, and fix the comment.Not re-run: disk-full (needs root), browser end-to-end tests including the webkit-390 flake, and the known one-off encode when undoing a 65 MiB paste.
Sign-out flake (review4-signout:131) and R8-1:
issue/652-signout-flakeat1f78184(off325ecc3)Commits:
d0ff772(R8-1),126f9d9(flake cause 1, product),940f597(flake cause 2, test),1f78184(e2e harness port).R8-1 (
d0ff772, product: client.ts)owedis now cleared only by an answer to a check sent after a step 2 went out since the resend request (owedStep2andowedCheck). The comment is corrected. New unit test (resync.test.ts, "an answer to a check queued before the gap…"): the refusal-pending window, a stale answer, a sibling edit forwarded behind IME, then the full step 2 and its answer. Before the fix the client showedsaved; after the fix it does not. A 3,000-trial model run is clean.The flake had two independent causes
I instrumented the app and test (temporary, not committed) and ran the test repeatedly on webkit-390.
1. A spurious held marker: product (a), but not a slow receipt. In all 3 "requires discard confirmation" failures, the daily note's held marker was written by
NoteSession.destroy()132–175 ms after the server's change arrived, when the fixture navigated on. The receipt itself was not slow. The marker was never cleared, because the note stayed closed, so the sign-out 11–15 s later warned. Verbatim debug from the failures:{"id":"day-2026-10-22","why":"destroy","ageMs":175}with heldAgeMs 12938,ageMs164 with 11432,ageMs132 with 15177. A real user leaving a note right after a collaborator change would get the same spurious warning.126f9d9): close still writes the marker at once (the last-copy safety), but the client now lingers without editor or local copy until the receipt arrives, at most 30 s, then clears the marker with a compare-and-clear (MetaStore.clearHeld). Reopening the note or signing out stops the wait, and a lingering client reports only held changes. ADR 0020 is updated.sync.test.ts"a note closed right after a collaborator change clears its held marker once the receipt arrives". Fails on325ecc3, passes now.2. A lost click: test (b). After fix 1, the remaining webkit-390 failures were 180 s timeouts, and the Sign out handler never ran. Instrumented marks were
nullin all 4 hangs, while all 26 passing runs ran it at once (enter → … → unsent=false). The test set the hash to account settings and clicked Sign out immediately. The passkey list above the button renders "Looking…" first, then loads and pushes the button down, so on slow phone-sized WebKit the click landed where the button had been.940f597): a sharedaccountReady()waits for that list (bounded, for offline cases) before every such click in the sign-out specs.holdLine's measurewritedispatching; harmless, left as is.)1f78184: the harness'sfreePort()can hand out browser-blocked ports on this host (ephemeral range 1024–65535). One run got 1723 and WebKit refused it withERR_UNSAFE_PORT; it now skips Fetch "bad ports".Proof (train environment)
webkit-390, ×30 (on
940f597):chromium-390, ×30 (on
1f78184):That chromium failure, and the one in the earlier ×30 run on
940f597(expect.poll … healthz … Received: 0, the server started too slowly under load), are fixture setup failing before the test (page.goto: net::ERR_NETWORK_CHANGEDat fixture line 238). Neither is sign-out behaviour.Full four-project browser suite (
1f78184):Editor vitest, tsc and the real-server suite (
940f597;1f78184changes onlyapps/web/e2e/harness.ts):Product code changed on this branch: client.ts (R8-1), plus note.ts and offline/meta.ts (the held-marker linger).
Delta review of issue/652-signout-flake (head
1f78184, since the approved325ecc3). Verdict: merge, nothing blocking.Findings:
/home/kayg/codex-jobs/history-review9/findings.md(on the host).R8-1 fix (
d0ff772).owednow clears only on an answer to a check sent after a step 2. In crates/notes, a held check is answered only after a step 2 fills the gap, so that answer really means the room stopped waiting. Answers to checks queued before the gap no longer clear it. Worst case,owedstays set until reconnect, which costs one step-2 diff per check. Liveness is fine.Linger after close (
126f9d9).stopNotes(sign-out) or the 30 s timer stops the client and leaves the room.stopNotesends it.Gates:
origin/dev (
c2b7a1a, #664) merged intoissue/652-signout-flake: head9f8131aThis is a merge, not a rebase. The conflicts were in
crates/notes/src/{bulk/mod.rs,history.rs,lib.rs,room/mod.rs}; batch.rs needed a follow-up edit. How each #652 path keeps #664's guarantees:HistoryWriter(Mutex<Option<SyncSender>>plus the joined thread). Every enqueue goes through oneHistory::send(), which refuses once shutdown has closed the queue. That covers plain, lazy and sized writes, the grouped room batches inhistory/batch.rs, and the test stall.History::shutdownstill joins the writer thread.Cmd::Shutdown. Shutdown has zero queue weight, like Leave and Flush, so a full payload budget cannot block it.RoomHandle::refused()uses the same queue type.Notes::enter(refused once shutdown starts) with the #652 byte-bounded input queue.spawn_background, joined at shutdown, never started afterwards). It still retries when the queued write failed (!matches!(.., Ok(Ok(())))).home.writable()before placing). Its group-commit and durability files are test modules, and no #652 code spawns untracked Home work.Gates on
9f8131a(verbatim):Merge-resolution review of
9f8131a(1f78184+ origin/devc2b7a1a/ #664). Verdict: merge. The conflict resolution keeps both #652's and #664's guarantees.Findings:
/home/kayg/codex-jobs/history-review10/findings.md(on the host).Conflict hunks checked
send(). That is a boundedtry_sendwith byte budgets, and it refuses afterclose().close()takes the only sender, lets the writer drain what was queued, and joins the thread.Shutdownweighs zero bytes, so a full byte budget can't block it; it still needs a count slot, as in #664's originalmpsc(4096).Ok(Err).Notes::enter.Gates on the merge binary
single_root_upgrade_…_rollback. Devc2b7a1afails the same way 7 of 50 times, so this is a pre-existing #664 test flake, not the merge.original_storage_startup_scenario_repeats_100x_under_load: ok.P2, pre-existing on dev (#664), not caused by the merge: shutdown is not bounded when history writes keep failing.
Cmd::Shutdownfirst runssettle()like any read command.settleerrors, the Shutdown is refused, and the actor keeps running.RoomHandle::shutdownthen waits for the room task with no timeout, so the process never finishes stopping and keeps its storage lock.grace::SETTLE.I ran the gates directly at nice 10 because other e2e runs held all three build slots for over 2 h while host load was about 2.
Landed in train AZ, #672.
Train AZ ran the full suite (run az2, dev
c2b7a1a+9f8131a): fmt, clippy, workspace tests, build, svelte-check, every Playwright project. Rust all green. Browser: admin 42+1, cr1440 331, cr390 254+208+2, wk1440 139+190+1, wk390 153 / 187+1 / 125, small 19. The failures were re-run 3x each on this head: refusal-performance (chromium-390, webkit-390) and task-check:29 = 18/18 passed; review4-signout:242 (webkit-1440) = 12/12 passed; admin-contrast is a known intermittent. Run az1 failed on the known storage_startup lock race (test-only, fix in progress on #664).Contents (#652): Saved means durably in history (receipts), temporary errors retry quietly, permanent size refusals show and clear once a fitting state is covered (incl. undo, offline), per-tab sign-out leases, Saved doesn't wait on collaborators, bounded queues, history order kept through failed writes, refusal path without per-key re-encodes or whole-note re-uploads, MessageChannel receipt drain, a closed note keeps its receipt wait (no false sign-out warning), real-server test suite in CI. Merged with #664 (bounded shutdown).
Independent review: 10 rounds; final verdicts merge on
325ecc3,1f78184(delta) and9f8131a(merge resolution). Known open: one 0.5-1.4 s stall when undoing a 65 MiB paste.Closing during the 26 Oct handover cleanup: Landed in train AZ (#672). The one open follow-up, a 0.5–1.4 s stall when undoing a 65 MiB paste, is carried in the handover #683.