You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hook_created branch in packages/world-local/src/storage/events-storage.ts now coordinates four non-atomic durable writes (token claim, recovery marker, event, hook entity). Each review round on #2295 surfaced a new crash window between two of them — entity-without-event, then claim-without-event, then event-without-entity — and each was patched with another recovery sub-branch.
The suggested refactor inverts the invariant: make the hook_created event in the event log the only source of truth, and treat the token claim, recovery marker, and hook entity as rebuildable caches. Any reader that misses the entity (or claim) rebuilds it from the persisted hook_created event. With that shape:
most of the dedup-recovery branching in the hook_created path collapses
new crash windows can no longer mint new bug classes, because partial cache state is always reconstructible from the log
the legacy-claim recovery-marker sidecar likely becomes unnecessary
Scope notes:
the same inversion may apply to other entity-creation paths (step_created, wait_created) that use claim/lock sidecar files
the existing regression tests in the concurrent entity-creation races describe block of packages/world-local/src/storage.test.ts should all keep passing and serve as the safety net for the refactor
Follow-up from #2295 (comment) (raised by @pranaygp).
The
hook_createdbranch inpackages/world-local/src/storage/events-storage.tsnow coordinates four non-atomic durable writes (token claim, recovery marker, event, hook entity). Each review round on #2295 surfaced a new crash window between two of them — entity-without-event, then claim-without-event, then event-without-entity — and each was patched with another recovery sub-branch.The suggested refactor inverts the invariant: make the
hook_createdevent in the event log the only source of truth, and treat the token claim, recovery marker, and hook entity as rebuildable caches. Any reader that misses the entity (or claim) rebuilds it from the persistedhook_createdevent. With that shape:hook_createdpath collapsesScope notes:
step_created,wait_created) that use claim/lock sidecar filesconcurrent entity-creation racesdescribe block ofpackages/world-local/src/storage.test.tsshould all keep passing and serve as the safety net for the refactor