Repository navigation
Rewrite as a minimal Bun/TypeScript library with map, set, list and Gk-trees - #6
Merged
Merged
Conversation
Replace the Deno sources with a small core (src/tree.ts) that follows the paper's unzip/zip formulation over a pluggable inner set, plus GMap, GSet and GList facades with JS-native APIs. Ranks are hashed by default so trees are history independent; random ranks remain available. Add Gk-trees (src/gk.ts) after Hehemann's thesis, section 4.1: node items become a G-tree of their own past a threshold, which bounds node sizes under adversarial keys. This drops in as another Items implementation. Tests run under bun test; a benchmark script picks k=8 as the default. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTbgsritf5j3MP1V7UsU3p
Replace Bun.hash with cyrb53 so the default rank works on any runtime; drop the bun export condition and add a Node smoke test of the built package to CI. Remove sideEffects: false, which made the bundler drop the re-exported facade modules. Add src/binary.ts, the classic binary zip tree with the same function names as the G-tree core, and tests that reproduce the paper's figure and unfold a k = 2 G-tree into the binary tree to check they coincide. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTbgsritf5j3MP1V7UsU3p
Replace the trailing-zero division loop with one logarithm plus an exact integer check against precomputed powers of k, so ranks cost the same for any k and are bit-identical across runtimes. Add tests against a BigInt reference at every boundary and for the geometric tail. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTbgsritf5j3MP1V7UsU3p
Make the Hash contract a 32-bit integer, the convention of xxHash32, MurmurHash3 and similar, and normalise signed results, so external hashes drop in without scaling. Fold the built-in hash to 32 bits to match. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTbgsritf5j3MP1V7UsU3p
3 tasks done
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.
Summary
Replaces the Deno sources with a small Bun/TypeScript library (about 680 lines in
src/) that follows the paper'sunzip/zipformulation and exposes usable map, set and list types.src/tree.ts): one G-tree implementation over a pluggable inner set.Itemshas six members and allows empty sets, so noSet<S>wrapper is needed. Insert iszip(zip(before, single), after), delete iszip(before, after); mapsetis therefore an upsert for free.GMap,GSet(JS-nativeget/set/has/delete/add/size, iteration in key order) andGList(positionalat/insert/remove/slice/concat/splitAt, sharingzip).src/rank.ts): hashed by default, so trees are history independent and structurally equal for equal sets;random(k)for keys with no hash.k = 2gives a zip tree, the defaultk = 8was picked by the benchmark.src/gk.ts), after Hehemann's thesis section 4.1:TreeItemsstores a node's entries as a G-tree with a reseeded rank (zip-zip trees on their own), andGkItemsis an array that converts to aTreeItemspast a threshold and back below it. Converting both ways at one size keeps history independence. NodeItemscarry aweightso rebuilding a tree-mode node stays O(1) rather than O(entries).bun test, 24 tests, invariant checker with a seeded PRNG), benchmark, typecheck, build with declarations, CI workflow, rewritten README.Notes
BinaryZipTree/ZipSequenceclasses are gone; a zip tree is now{ k: 2 }, represented as the paper's runs-of-equal-rank form rather than left/right binary nodes.Bun.hash; other runtimes need a customrank.12k: a single threshold with hysteresis would be history dependent, and at12khonest nodes essentially never convert, while a node pinned at the threshold by an adversary costs a bounded constant.Test plan
bun run typecheckbun testbun run buildbun run bench(k=8 fastest for insert/get; Gk variant within noise of plain on honest data)🤖 Generated with Claude Code
https://claude.ai/code/session_01NTbgsritf5j3MP1V7UsU3p
Generated by Claude Code