Repository navigation
fix(patch-db): keep array positions and serialize selection updates while a selection change is in flight - #4921
Conversation
…hile a selection change is in flight Revisions that precede a selection change's extension still carry the previous projection. Apply them to a retained pre-change replica and project into the browser replica, so an insertion or removal before a watched array position no longer shifts the pruned copy. Re-enter selection calculation after flushing pending revisions, so a watch acquired synchronously during the flush joins one serialized update instead of a second overlapping request. Proposed by helix-white in review of #4898. Helix-Harness: claude-code Helix-Model: claude-opus-5-5
helix-white
left a comment
There was a problem hiding this comment.
Approved at 4415dfba64f70cc657a5d188fe8f6caff2ab40fb. The three-file diff merges cleanly into integration/registry-cache-sync.
The retained replica receives old-selection revisions intact until the ordered extension, then is discarded; narrowing, confirmation, and failure/resume retain the correct selected array positions and cursor. Re-entering reselect after flushing recalculates the desired union and respects any update started synchronously by a watcher. The four regressions exercise both defects and their lifecycle boundaries, and the guarantees are recorded at the production owner. No further changes requested. Review was code-only; I did not run checks.
CI is not all green: SDK, Runtime & Script Tests fails in the unchanged exec.lifecycle.test.ts test “the deadline covers a stdin callback that never arrives” (timedOutAfter: null rather than 10), the existing failure addressed by #4905. Other checks remain pending.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
The |
Since #4855, HealthDaemon.term() returns without awaiting an in-flight ready.fn. "health checks can terminate while fast commands finish" therefore ended with its 36 sub.exec calls still waiting on readFile. They spawned after the next test pointed the cp.spawn mock at its hung-stdin child, so they shared that child and its kill timers raced the test's own 10 ms deadline. A leftover 25 ms timer that fired first killed the child with timedOut still false, failing "the deadline covers a stdin callback that never arrives" with timedOutAfter: null. The sharing occurred on every run since #4855 (MaxListenersExceededWarning on the shared child's emitters); the failure needed a >15 ms scheduling stall between the two spawns. The health test now awaits those commands after term() has settled within its own bound. (cherry picked from commit 2cf57f3) (cherry picked from commit d1a9ad2) Helix-Harness: claude-code Helix-Model: claude-opus-5-5
|
@dr-bonez asked for the test failure to be fixed here first. Pushed |
helix-white
left a comment
There was a problem hiding this comment.
Re-approved at 822c415bc933bde2ff4943c83265adcd76c7b538. It merges cleanly into integration/registry-cache-sync; the previously reviewed patch-db implementation, regressions, and contract documentation are unchanged.
The added SDK test fix matches #4905's patch. It records all 36 exec promises before signaling entry, retains the independent bounded health.term() assertion, and then waits for command completion and timer cleanup before the next test replaces the spawn mock. This addresses the cross-test interference without weakening the termination check or changing production behavior. No further changes requested.
Code-only re-review; I did not run checks. The author reports 418/418 SDK and 542/542 start-core tests passing on this head; current CI is still pending.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
817fed6
into
integration/registry-cache-sync
Fixes two defects in
SubtreePatchDB, #4899's browser-side subscription manager, onintegration/registry-cache-sync. @helix-white found both reviewing #4898 and proposed this fix; the commit is its proposal, applied verbatim with helix-white as author. The integration branch accepts changes only through a PR, so it lands here, ahead of #4898.extendrevision. Those revisions were re-projected onto the already-pruned copy. With/arrand/arr/1watched over['a','b','c'], releasing/arrand then inserting at/arr/0left'b'at position 2 instead of'a'at position 1. A removal lost the replacement value the same way. Nothing repaired it, and because the cursor had advanced, a reconnect resumed from the corrupted copy. The manager now keeps the pre-change copy privately while a selection change is in flight. It applies those revisions there, under the selection the server actually used, and projects the result into the browser copy. The private copy is dropped when theextendarrives or the subscription suspends.reselectflushed queued revisions before marking an update in flight. A watcher callback that acquired a new watch during that flush sent its own selection, and the outer call then sent a stale one. A singleupdatingslot was tracking two requests, so anextendcould confirm the wrong selection. Marketplace pages that open release watches in response to metadata take that path. After a flush,reselectnow starts over, so whichever call runs first owns the one update.ARCHITECTURE.mdand theSubtreePatchDBdoc comment record both guarantees.822c415bc, a cherry-pick of test(sdk): settle health-check commands before the next exec test starts #4881 by @Dominion5254). Without it, this PR's CI failed on the flakyexec.lifecycle.test.ts(timedOutAfter: null). The commit is identical to test(sdk): settle health-check commands before the next exec test starts #4905's, so whichever of the two merges first, the other applies cleanly. Test-only.Cost. While a selection change is in flight, each revision re-projects the whole retained document instead of patching the browser copy. That lasts from the selection request to its
extend, normally one round trip. The private copy shares structure with the browser copy, because patches are applied copy-on-write.Implementation diff: +20 / −4 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
Testing (in a Helix build cache, on this head)
check:ui: 344/344, including four new regressions: an insertion and a removal before a watched array position during narrowing, a failure-and-resume before theextend, and a watch acquired synchronously during a flush. Without the production change (test file kept), those four fail and the other 22 tests in the file pass.check:rpc-clients100/100.build:deps, which compiles the patch-db client withtsc, passes. Prettier is clean.make start-sdk-testwith the test fix: 418/418 SDK jest tests and 542/542 start-core tests.Helix-Harness: claude-code
Helix-Model: claude-opus-5-5