Repository navigation
Conversation
…p, and clear clock
|
@Pybsama is attempting to deploy a commit to the nehanth's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Four edge cases in
packages/room-node/ckpt.js(CkptIndex) could corrupt or mismanage checkpoint slots:nextKey()wrapped(this.n % 65534) + 1without checking whether the slot number was still live inthis.ix.items. On a long-running host, wrapping past 65,534 reuses slot1and overwrites a still-pinned system prompt checkpoint (or a slot scheduled for eviction whosedprides aftersv).plan()clampedcapwithMath.max(1, pin ? this.pins : this.answers). Whenpins === 0(whichroomnode.jsexplicitly configures for 1-slot Flash rooms via{ answers: 1, pins: 0 }) oranswers === 0,plan()still allocated and saved a slot, exceeding the room's checkpoint reserve.best(ids, reused)delegated tothis.ix.best(ids), which bumpeditem.t = ++clockeven whenb.n <= reusedcausedCkptIndex.best()to reject the checkpoint and count a miss — keeping unused pinned checkpoints artificially fresh.clear()emptiedthis.ix.itemswithout resetting GreedyDual clockthis.Lback to0.Changes
CkptIndex.nextKey()(throwing if all 65,534 slots are simultaneously live).CkptIndex.plan()by returning{ skip: true, key: null }without dropping existing checkpoints or advancingthis.L, and allocatekeybefore advancingthis.L.reuseddirectly inCkptIndex.best()sotouch()only runs on actual hits.this.L = 0inCkptIndex.clear().packages/room-node/test/ckpt_test.mjs.Verification
node --check packages/room-node/ckpt.js packages/room-node/test/ckpt_test.mjs: OKnode --test packages/room-node/test/ckpt_test.mjs: 14 passed, 0 failednpm run test:packages: 217 passed, 6 skipped, 0 failednpm run test:runtime: PASS (6/6 checks, 172 frames)