pi-mono/packages/chord/test
badlogic c4289b20eb fix(chord): keep tracked paths correct across structural mutation
A wrapper baked its path at creation, so a reference held across a
structural mutation kept addressing its old index: unshift then a write
through a held element edited its neighbour, and a write after a splice
could produce a path the replica cannot resolve. The baseline diff this
tracker replaced was immune, because its dirty paths were only hints and
the ops came from comparing values.

A wrapper now holds a cell (parent link plus segment) and the path is
walked at use time, so renumbering an element corrects every descendant.
pop/shift/unshift/splice and length truncation shift live children by the
delta and mark removed ones dead; sort/reverse/fill/copyWithin relocate
them by identity. Renumbering iterates a set of live cells rather than the
lookup cache, which is keyed by index and can evict a child that is still
held. Writes through an element that left the document mutate it and
record nothing, as plain JS and the baseline diff both do.

One object can occupy several positions in the tree. A wrapper is now
shared per target and holds a cell per position, and a write emits an op
for each, which is what the baseline diff produced for the same shape.
Positions are registered when a path is read, when a tracked value is
assigned elsewhere, and when one is inserted by an array mutator (only the
inserted range is examined; scanning the array made every structural
mutation O(n)). A blocked view of an object gets its own wrapper so the
reserved-key guard cannot be bypassed through a safe alias.

Paths are cached per cell against a counter that only structural mutation
bumps, and the per-write cell walk is skipped until a document actually
aliases something.
2026-09-18 00:32:50 +00:00
..
boundary.test.ts feat: move facet services into Chord 2026-08-29 14:55:51 +02:00
bundle.test.ts feat: make Chord facet generations collectible 2026-08-31 00:13:44 +02:00
context.test.ts feat: isolate Chord context API 2026-08-29 20:01:32 +02:00
delta.test.ts fix(chord): keep tracked paths correct across structural mutation 2026-09-18 00:32:50 +00:00
facet-loader.test.ts fix(chord): make post-cutover reload failures terminal 2026-09-01 16:16:12 +02:00
facets.test.ts fix(chord): make post-cutover reload failures terminal 2026-09-01 16:16:12 +02:00
helpers.ts fix: harden Chord service lifecycle semantics 2026-08-30 01:00:26 +02:00
json.test.ts feat: add delta-backed replicated state 2026-08-31 14:04:42 +02:00
service-wire.test.ts feat: consolidate remote service adapters 2026-09-01 10:09:01 +02:00
services.test.ts feat(chord): replace delta tracker with operation log 2026-09-17 16:36:37 +02:00