Roaring bitmap sync

From FgForrest/evitaDB · View interactive version

Roaring bitmap sync is an AI agent skill from the GitHub repository FgForrest/evitaDB. Replay upstream RoaringBitmap changes onto the vendored evita_roaring_bitmap module. Walks upstream/master since the recorded base, triages each commit against the vendored subset, incorporates relevant fixes, and updates the sync ledger. Invoke when checking for or applying upstream RoaringBitmap u

How to use this skill

Skill file

RoaringBitmap Upstream Sync

evita_roaring_bitmap/ vendors a subset of RoaringBitmap

(Apache-2.0), reshaped into one persistent bitmap per data type. This skill replays upstream

changes onto that vendored copy: identify the upstream commit our sources correspond to, walk every

upstream commit since, understand each change, and incorporate the ones that touch code we kept.

The authoritative state lives in evita_roaring_bitmap/UPSTREAM_SYNC.md — read it first, update it last.

Key facts (do not re-derive from scratch)

its directory. Its suite runs twice, once per kernel configuration (target/surefire-reports and

target/surefire-reports-scalar), so read both XML directories.

origin = fork novoj/RoaringBitmap, upstream = RoaringBitmap/RoaringBitmap. Upstream default branch is master.

The clone has been absent in recent reviews; then clone https://github.com/RoaringBitmap/RoaringBitmap.git

into the scratchpad (--filter=blob:none is enough) and use its origin as upstream.

boolean[] shared array alongside highLowContainer. **Any ported code that populates highLowContainer

must keep shared sized in lockstep** (call ensureSharedCapacity(highLowContainer.size()) after growth,

or new boolean[...]). This is the single most common porting landmine — see "Porting caveats".

Procedure

1. Read the ledger and establish coordinates

batcat documentation/RoaringBitmap/../../evita_roaring_bitmap/UPSTREAM_SYNC.md   # or just Read it

Note the base commit (where our sources forked) and reviewed-through (last commit triaged).

2. Fetch upstream and find the new range

cd documentation/RoaringBitmap
git fetch upstream --tags
git rev-parse upstream/master                      # current tip
git log --reverse --oneline <reviewed-through>..upstream/master

If the range is empty, we are current — report that and stop. Otherwise that list is the work queue.

(Sanity-check the base: git merge-base origin/master upstream/master should equal the recorded base commit.)

3. Triage each commit (files changed → disposition)

git log --reverse --stat --format='%n>>> %h %s' <reviewed-through>..upstream/master

For each commit, classify by the files it touches, using the exclusions and class mapping in

UPSTREAM_SYNC.md:

FrozenRoaringBitmap, FastRankRoaringBitmap, longlong/Roaring64NavigableMap, or build/docs files

(gradle.properties, build.gradle.kts, README.md, AGENTS.md, jmh/, fuzz-tests/, examples/, bsi/).

new upstream fix is often one of those rows coming back (seven of Review 4's fixes were). Compare the two fixes,

keep the stricter, and move the row to the review's sync-log section, saying which one was kept and why.

⚠️ Roaring64NavigableMap is NOT our 64-bit class. Our PersistentLongRoaringBitmap derives from

the ART-based Roaring64Bitmap. A fix to NavigableMap's cumulative-high cache (minHigh,

firstHighNotValid, ensureCumulatives, ensureOne, sortedHighs) does not apply — verify with a

grep that the symbol genuinely doesn't exist in our sources before declaring N/A, but expect N/A.

4. For each investigate-worthy commit: understand, then check applicability

git show <hash> -- roaringbitmap/src/main/java/org/roaringbitmap/<File>.java
git log -1 --format='%B' <hash>

Read the full diff and the message. Then confirm whether the changed code path **exists in our vendored

copy** (it may target an overload/constructor/field we dropped, e.g. anything taking an

ImmutableRoaringBitmap). Map the upstream line to ours:

grep -n "<method-or-symbol>" evita_roaring_bitmap/src/main/java/io/evitadb/roaringbitmap/<MappedFile>.java

Decide:

5. Incorporate applicable changes

Apply the upstream hunk to the mapped file by hand (don't git cherry-pick — packages and class names

differ). Re-indent to tabs. Rename org.roaringbitmap → io.evitadb.roaringbitmap,

RoaringBitmap → PersistentRoaringBitmap, Roaring64Bitmap → PersistentLongRoaringBitmap.

⚠️ Respect the JPMS encapsulation reshaping documented in UPSTREAM_SYNC.md (its "JPMS

encapsulation reshaping" section): the 64-bit bitmap + its API interfaces live in the root

package (not longlong); longlong/art are not exported; ArraysShim is gone (use

java.util.Arrays); and several core classes were demoted public → package-private. If an upstream

edit re-introduces public on a demoted class or re-adds ArraysShim, re-apply the evita change.

If upstream shipped a test for the fix, port it too (into src/test/java/io/evitadb/roaringbitmap/)

with the same renames, unless it targets a dropped type.

Porting caveats

RoaringArray-level append/insertNewKeyValueAt must keep shared sized to match. Static/all-owned

builders that leave shared at default capacity have caused AIOOBE four times. After any growth, ensure

shared.length >= highLowContainer.size (via ensureSharedCapacity) before any in-place op reads

shared[i] by raw index. Treating an index ≥ shared.length as "owned/false" is correct because only the

three sharing paths (newAllSharedResult / borrowAndInsert / appendTailWithSharing) ever create shared

containers and all of them size shared[].

GenericEvitaInternalError on truly-unreachable paths.

6. Update the ledger and NOTICE

In UPSTREAM_SYNC.md:

point; normally the base stays put and only "reviewed through" advances.

In NOTICE: update the "reviewed through commit … (effective coverage vX.Y.Z)" line.

7. Verify and commit

cd evita_roaring_bitmap && mvn -o test         # builds this module alone; runs the suite twice

Module suite must stay green (19,2xx+ tests in each of the two executions, summed from the XML reports). Then — only with Johnny's go-ahead (the standing

no-git-without-permission rule applies) — commit on the task branch:

docs: sync RoaringBitmap vendoring through <short-hash> (review N)

<one line per incorporated change, or "no functional changes; subset already current">

Ref: #1252

Output

Report a short table: each upstream commit since the previous reviewed-through, its kind

(code/build/docs), what it touches, and the disposition (incorporated / no-op / N/A-dropped). State the

net result and the new reviewed-through commit. If anything was genuinely ambiguous (a fix that might

apply to a kept class but is non-obvious), surface it to Johnny rather than guessing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.