Skip to content

Rebuild structures from durable store when a save is declined (v2) - #187

Merged
kriszyp merged 1 commit into
masterfrom
kris/savestructures-uninitialized-v2
Jun 8, 2026
Merged

kriszyp merged 1 commit into
masterfrom
kris/savestructures-uninitialized-v2

Conversation

@kriszyp

@kriszyp kriszyp commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

v2 port of #186. When saveStructures returns false (concurrent shared-structures update, or the host store transaction did not durably commit), mark structures uninitialized before re-packing so the re-pack reloads durable structures via getStructures, rebuilds the transition trie, and re-mints + re-saves — instead of re-emitting the same record referencing a structure id that was never persisted (→ Record id is not defined for N on a fresh reader).

See #186 (v1.11.x) for the full root-cause writeup and the paired host-side fix. One-line pack.js change + a regression test ("declined structure save re-packs against durable structures").

🤖 Generated by Claude (Opus 4.7).

Port of the v1.11.x fix to v2. When saveStructures returns false (a concurrent
writer updated the shared structures, or the host store transaction did not
durably commit), the encoder's in-memory structures + transition trie may
reference record ids that were never persisted. The existing re-pack reused the
cached transition and re-emitted the same record pointing at an unpersisted
structure -> "Record id is not defined for N" on a fresh reader.

Mark structures uninitialized before the re-pack so it reloads durable structures
via getStructures, rebuilds the trie, and re-mints + re-saves.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@kriszyp
kriszyp marked this pull request as ready for review June 8, 2026 11:32
@kriszyp
kriszyp merged commit 64a906e into master Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant