@cloudbitmaps/roaring 0.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +12 -0
  3. package/PRIVACY.md +185 -0
  4. package/README.md +40 -0
  5. package/dist/azure/index.cjs +14 -0
  6. package/dist/azure/index.cjs.map +1 -0
  7. package/dist/azure/index.d.cts +9 -0
  8. package/dist/azure/index.d.ts +9 -0
  9. package/dist/azure/index.js +3 -0
  10. package/dist/azure/index.js.map +1 -0
  11. package/dist/bin/compact-segments.js +133 -0
  12. package/dist/bin/compact-segments.js.map +1 -0
  13. package/dist/bin/export-segments.js +131 -0
  14. package/dist/bin/export-segments.js.map +1 -0
  15. package/dist/cassandra/index.cjs +14 -0
  16. package/dist/cassandra/index.cjs.map +1 -0
  17. package/dist/cassandra/index.d.cts +1 -0
  18. package/dist/cassandra/index.d.ts +1 -0
  19. package/dist/cassandra/index.js +3 -0
  20. package/dist/cassandra/index.js.map +1 -0
  21. package/dist/chunk-JWCQLJUG.js +573 -0
  22. package/dist/chunk-JWCQLJUG.js.map +1 -0
  23. package/dist/dynamodb/index.cjs +14 -0
  24. package/dist/dynamodb/index.cjs.map +1 -0
  25. package/dist/dynamodb/index.d.cts +1 -0
  26. package/dist/dynamodb/index.d.ts +1 -0
  27. package/dist/dynamodb/index.js +3 -0
  28. package/dist/dynamodb/index.js.map +1 -0
  29. package/dist/gcs/index.cjs +14 -0
  30. package/dist/gcs/index.cjs.map +1 -0
  31. package/dist/gcs/index.d.cts +1 -0
  32. package/dist/gcs/index.d.ts +1 -0
  33. package/dist/gcs/index.js +3 -0
  34. package/dist/gcs/index.js.map +1 -0
  35. package/dist/index.cjs +561 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.cts +446 -0
  38. package/dist/index.d.ts +446 -0
  39. package/dist/index.js +542 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/mongodb/index.cjs +14 -0
  42. package/dist/mongodb/index.cjs.map +1 -0
  43. package/dist/mongodb/index.d.cts +1 -0
  44. package/dist/mongodb/index.d.ts +1 -0
  45. package/dist/mongodb/index.js +3 -0
  46. package/dist/mongodb/index.js.map +1 -0
  47. package/dist/mysql/index.cjs +14 -0
  48. package/dist/mysql/index.cjs.map +1 -0
  49. package/dist/mysql/index.d.cts +1 -0
  50. package/dist/mysql/index.d.ts +1 -0
  51. package/dist/mysql/index.js +3 -0
  52. package/dist/mysql/index.js.map +1 -0
  53. package/dist/postgres/index.cjs +14 -0
  54. package/dist/postgres/index.cjs.map +1 -0
  55. package/dist/postgres/index.d.cts +1 -0
  56. package/dist/postgres/index.d.ts +1 -0
  57. package/dist/postgres/index.js +3 -0
  58. package/dist/postgres/index.js.map +1 -0
  59. package/dist/redis/index.cjs +14 -0
  60. package/dist/redis/index.cjs.map +1 -0
  61. package/dist/redis/index.d.cts +1 -0
  62. package/dist/redis/index.d.ts +1 -0
  63. package/dist/redis/index.js +3 -0
  64. package/dist/redis/index.js.map +1 -0
  65. package/dist/s3/index.cjs +14 -0
  66. package/dist/s3/index.cjs.map +1 -0
  67. package/dist/s3/index.d.cts +1 -0
  68. package/dist/s3/index.d.ts +1 -0
  69. package/dist/s3/index.js +3 -0
  70. package/dist/s3/index.js.map +1 -0
  71. package/package.json +183 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ CloudRoaring
2
+ Copyright 2026 Sharvil Kadam
3
+
4
+ This product includes software developed as an open-source project.
5
+ Licensed under the Apache License, Version 2.0 (the "License"); see the LICENSE
6
+ file. You may obtain a copy of the License at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ CloudRoaring builds on the Roaring Bitmap data structure and is designed to use
11
+ the CRoaring engine (via the `roaring` Node.js binding) for in-memory bit math.
12
+ Those projects are independent works under their own licenses.
package/PRIVACY.md ADDED
@@ -0,0 +1,185 @@
1
+ # Privacy, data protection & shared responsibility
2
+
3
+ > **Engineering guidance, not legal advice.** This document explains CloudRoaring's data-handling posture and
4
+ > the controls it gives you, so you (and your privacy counsel / DPO) can place it correctly in your compliance
5
+ > program. Regulatory references (GDPR, CCPA/CPRA, HIPAA, …) are illustrative. Nothing here is a compliance
6
+ > certification — before deploying against personal data, get it reviewed by qualified counsel.
7
+
8
+ ## TL;DR — the trust boundary
9
+
10
+ **CloudRoaring is an embedded library.** It runs inside *your* process/function and talks to *your* storage
11
+ accounts (S3, DynamoDB, local disk — whatever drivers you wire). **It has no hosted backend and transmits no
12
+ data to the authors or any third party** — there is no telemetry, no phone-home, no usage ping. The metrics
13
+ and audit sinks are local and off by default; they only go where *you* send them.
14
+
15
+ Consequently: **you are the data controller (and/or processor); CloudRoaring is not a sub-processor.** There is
16
+ no SaaS relationship and no data-processing agreement to sign with us, because no data ever reaches us. What
17
+ the library gives you is a set of *mechanisms* — you own the *policy*.
18
+
19
+ ## What CloudRoaring processes — and why it's usually personal data
20
+
21
+ CloudRoaring's job is to store, at scale, **the fact that an integer ID belongs to a named set**. The moment
22
+ that ID is (or can be linked to) a natural person — which is the intended use — that membership bit is
23
+ **personal data**. Often it is behavioural/inference data, and **membership alone can be special-category**:
24
+ a segment that means "pregnant", "in HIV outreach", "flagged for fraud", "likely-LGBTQ", or
25
+ "political-affiliation" makes the single bit `id ∈ segment` GDPR Art. 9 / CPRA sensitive data, needing an
26
+ explicit lawful basis and heightened safeguards.
27
+
28
+ **The library cannot see this.** It handles opaque integer IDs in named segments and applies uniform controls;
29
+ it has no way to know segment 7 is sensitive. **Classifying your segments is your responsibility** (see the
30
+ matrix below). If a segment holds special-category data, you should pair it with encryption (a keystore) and
31
+ an audit sink, and a short retention.
32
+
33
+ ## Where the data lives — the transfer / residency surface
34
+
35
+ You choose every storage location by wiring the drivers, so **data residency is under your control — and your
36
+ responsibility.** The library never moves data to a region you didn't configure, but it also won't stop you
37
+ from constructing a cross-region topology. The points where personal data moves or is processed:
38
+
39
+ | Location | What's there | Residency note |
40
+ |---|---|---|
41
+ | **Cold** (object store) | immutable `.crbm` generations | the region of the bucket you wire |
42
+ | **Warm** (NoSQL) | pending add/remove deltas | the region of the table you wire |
43
+ | **HOT cache** (process RAM) | decoded chunks, bounded LRU | **wherever your process/Lambda runs** — an EU segment queried from a US function is processed in the US |
44
+ | **Compaction** (daemon) | reads Cold+Warm, writes new Cold | runs wherever you run the daemon |
45
+ | **Intersection** | pulls chunks from N segments into one process | co-locates those segments in one region |
46
+
47
+ **Guidance (not enforced by the library):** to keep EU data in EU infrastructure, wire region-local drivers
48
+ *and* run the process/daemon in-region; keep a segment's Warm, Cold, and the querying compute in one
49
+ jurisdiction; treat the HOT cache and the intersection runtime as **processing locations** in your transfer
50
+ assessment and breach scope (process RAM, and any heap/core dumps, hold personal data). A fail-closed
51
+ residency-enforcement policy in the library was considered and deferred as over-engineering for v1 — the honest
52
+ posture is "you wire it correctly," documented here.
53
+
54
+ ## Erasure — what "delete" actually means
55
+
56
+ CloudRoaring gives you three erasure levers with different guarantees. Use them deliberately:
57
+
58
+ | Lever | API | Guarantee | Use for |
59
+ |---|---|---|---|
60
+ | **Logical remove** | `segment.remove(id)` / `removeMany` | *Immediate* — reads exclude the ID at once (tombstone; `effective = (Cold ∪ adds) \ removes`). The bit **physically persists** in the immutable Cold `.crbm` until that chunk is next compacted. | everyday "take this user out of this audience" |
61
+ | **Physical purge** | `store.compact(ref, { owner })` on demand, or the compaction daemon (`compact-segments` / `runCompactionCycle`) on a schedule | A compaction folds the tombstone into a fresh generation and **physically drops** the bit. | meeting a physical-deletion deadline — *run compaction (the daemon on a schedule, or `store.compact` on demand) inside your SLA* |
62
+ | **Crypto-shred** | `destroySegment` / `eraseNamespace` | *Instant + total* — destroys the segment's wrapped key, so **every** copy (current, prior generations, backups, WORM-locked objects) becomes unreadable without touching the bytes. Requires the segment to be encrypted. | whole-segment / tenant offboarding; erasure under immutable backups (see below) |
63
+
64
+ **Subject-wide erasure** (GDPR Art. 17 — "forget this person everywhere") is `store.eraseSubject(id, { owner })`:
65
+ it removes the id from every **registered** segment it's in *and* force-compacts those segments on the spot, so
66
+ the bit is physically gone from Cold on return — even for idle/archival segments organic compaction would never
67
+ touch. It reuses the store's own drivers (so build the store with a raw cold driver + a registry). It returns an
68
+ **erasure ledger** (per-segment: removed / physically-purged / which generation retired the bit) as your proof
69
+ of deletion; persist it or route it to your audit sink. `store.subjectReport(id)` answers the read side (Art. 15
70
+ — which segments an id is in). Run erasure without concurrently re-adding the same id; any ledger entry with
71
+ `physicallyPurged:false` (a held compaction lease, or an isolated fault) needs a follow-up `store.compact(ref)` —
72
+ re-running `eraseSubject` won't re-purge it.
73
+
74
+ **Your exit path** (and a building block for a **data-portability / Art. 20** response): `store.exportSegments(sink,
75
+ { format })` (and the `export-segments` CLI) dumps every registered segment's effective set to a portable file —
76
+ `roaring` (loadable by any roaring library) or `ndjson` (newline ids) — readable without CloudRoaring. It's a
77
+ **controller-side bulk dump** (all segments, opaque ids), not a per-subject deliverable — the per-subject rights
78
+ are `subjectReport` (Art. 15) / `eraseSubject` (Art. 17). Encrypted segments are decrypted transparently if the
79
+ store has the keystore, so the **export is cleartext — protect it** (the CLI writes owner-only files; also encrypt
80
+ the dump at rest, restrict access, and delete it when done).
81
+
82
+ **Honest limits.** Logical `remove()` is *not* physical deletion on its own — you need compaction (which
83
+ `eraseSubject` forces, or a scheduled daemon), or crypto-shred. **Per-subject crypto-shred is infeasible** (a
84
+ subject's bit is co-mingled with millions of others in one shared container), so single-subject erasure goes
85
+ through remove + compaction (`eraseSubject`), while crypto-shred (`destroySegment`/`eraseNamespace`) cleanly
86
+ handles segment/tenant-level erasure and is the only erasure that survives immutable backups / WORM.
87
+
88
+ **Erasure vs. backups / WORM (the trap).** If you enable S3 versioning, Object Lock, or DynamoDB PITR for
89
+ durability, a `remove()`+compaction *does not* reach the retained copies — the deleted bit survives in
90
+ noncurrent versions, locked objects, and backups. **Crypto-shred is the only erasure that survives all of
91
+ them**, because it destroys the key, not the bytes. So: use **per-segment/tenant encryption** as your erasure
92
+ posture under immutable storage; reserve S3 Object Lock **COMPLIANCE** mode for data under a genuine legal
93
+ hold (it *cannot* be deleted before its retention date, by anyone — incompatible with on-demand erasure), and
94
+ prefer **GOVERNANCE** mode where erasure must remain possible.
95
+
96
+ ## Retention & data minimization
97
+
98
+ The library does not age data out for you — segments grow until you prune them, and "cheap to keep forever" is
99
+ a storage-limitation anti-pattern if the data is personal. **Retention policy is yours.** Practical patterns:
100
+
101
+ - **Rolling windows** (e.g. "active this week"): keep N daily sub-segments, union them for reads, and drop the
102
+ oldest wholesale — turning retention into cheap whole-segment deletion (an object delete or crypto-shred),
103
+ not per-bit aging.
104
+ - **Scheduled compaction** enforces any tombstones you've written for aged-out members within your window.
105
+ - Surface segment age/size via the **metrics sink** so unbounded growth is visible, not silent.
106
+
107
+ ## Legal hold
108
+
109
+ A litigation/regulatory hold *forbids* deletion — the opposite of erasure — and can apply to the same segment.
110
+ **Enforce a hold with S3 Object Lock**, which is the real, tamper-proof mechanism: in **COMPLIANCE** mode a
111
+ locked Cold object *cannot* be deleted before its retention date by anyone (not even the account root); in
112
+ **GOVERNANCE** mode a privileged role can override. To place a hold on a segment:
113
+
114
+ 1. Enable **Object Lock** on the segment's Cold `.crbm` objects (and enable versioning) for the hold period.
115
+ 2. **Exclude the segment from your compaction and erasure runs** — don't call `eraseSubject`, `destroySegment`,
116
+ or the compaction daemon against held segments, so the current generation (and its members) is preserved.
117
+ 3. Decide hold-vs-erasure precedence when both apply to the same subject — that is a **legal determination**;
118
+ under a hold, erasure is suspended.
119
+
120
+ CloudRoaring deliberately does **not** ship a native `legalHold` flag: Object Lock is a stronger guarantee than
121
+ an in-library flag (which our own daemon could respect but a direct caller could bypass), so a flag would be
122
+ advisory where Object Lock is enforced at rest. If a real deployment needs a library-managed hold that the
123
+ daemon refuses to purge, it's a clean fast-follow — but the enforced posture is Object Lock + operational
124
+ exclusion, documented here (P10).
125
+
126
+ ## Audit & accountability (GDPR Art. 30 / Art. 5(2))
127
+
128
+ Wire the **audit sink** (`IAuditSink`) to get an append-only, vendor-neutral record of the compliance-relevant
129
+ state changes — `segment.publish`, `segment.compact`, `segment.erase` (a genuine crypto-shred), and
130
+ `namespace.erase` — for your audit log / SIEM. It is off by default and exception-safe. See the
131
+ [dashboards guide](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/dashboards.md). An erasure *ledger* — per-subject-request proof of physical
132
+ deletion — is returned by `subjectReport` / `eraseSubject` (shipped in Phase 6b).
133
+
134
+ **Log hygiene:** `segment` / `namespace` are *your* strings and may encode sensitive purpose; IDs are personal
135
+ data. The library never logs bitmap contents or raw IDs, but **you** should treat segment names and IDs as PII
136
+ in your own logs, error reporting, and metric/trace tags — hash or redact them, and prefer opaque/coded
137
+ segment names for sensitive segments (keeping the human label in your own classified registry).
138
+
139
+ ## Shared-responsibility matrix
140
+
141
+ | Concern | CloudRoaring provides | You (the integrator) must |
142
+ |---|---|---|
143
+ | **Controller/processor role** | an embedded library; sends nothing to us | be the controller/processor; run your own DPAs with *your* cloud providers |
144
+ | **Encryption at rest** | AES-256-GCM envelope encryption, BYOK keystore (`InProcessKeystore`), per-segment DEK + active/recovery KEK | hold and protect your keys (KMS/HSM); enable encryption for sensitive segments |
145
+ | **Erasure** | `remove` (logical), compaction (physical), `destroySegment`/`eraseNamespace` (crypto-shred) | run compaction within your SLA; choose crypto-shred under WORM/backups; classify what needs erasing |
146
+ | **Residency** | region-agnostic drivers; you choose every location | wire region-correct drivers; run compute in-region; assess transfers |
147
+ | **Classification** | opaque handling; a place to keep sensitive segments encrypted + audited | classify your segments (the library can't infer sensitivity) |
148
+ | **Retention** | scheduled compaction; rolling-window pattern | set and enforce retention windows |
149
+ | **Legal hold** | Object Lock guidance (the enforced mechanism; no in-library flag) | place holds via Object Lock; exclude held segments from compaction/erasure; decide precedence |
150
+ | **Accountability** | `IAuditSink` (publish/compact/erase events) | route it to durable, append-only storage; keep your Art. 30 record |
151
+ | **Telemetry** | **none** — no phone-home | (nothing — there is nothing to disable) |
152
+
153
+ ## DPIA skeleton (for deployments with sensitive segments)
154
+
155
+ A minimal Data-Protection-Impact-Assessment outline to adapt:
156
+
157
+ 1. **Processing description** — which segments, what each membership *means*, source of the IDs, volume.
158
+ 2. **Necessity & proportionality** — lawful basis per segment (esp. Art. 9 special-category); why membership
159
+ is retained and for how long.
160
+ 3. **Data flow & residency** — Warm/Cold regions, where compute (HOT cache, intersection) runs, cross-border
161
+ transfers and their safeguards.
162
+ 4. **Risks** — re-identification, sensitive inference (incl. *derived* segments from intersections — treat a
163
+ `paying ∩ pregnant` result as at least as sensitive as its inputs, and note it's a point-in-time snapshot
164
+ that does not auto-honour later erasures of source members), breach scope (incl. process RAM / dumps).
165
+ 5. **Controls** — encryption + crypto-shred, erasure SLA (scheduled compaction), retention windows, audit
166
+ sink, access control on keys and storage, redaction of names/IDs in logs.
167
+ 6. **Residual risk & sign-off** — DPO review.
168
+
169
+ ## Art. 30 record — mapping template
170
+
171
+ Map CloudRoaring's processing onto the categories a record of processing needs:
172
+
173
+ | Art. 30 field | CloudRoaring mapping |
174
+ |---|---|
175
+ | Categories of processing | storage of set-membership; set intersection; compaction; caching |
176
+ | Categories of data subjects / data | your IDs' subjects; membership (possibly special-category) |
177
+ | Recipients | none external to your infrastructure (no sub-processor) |
178
+ | Transfers | any cross-region driver/compute topology *you* configure |
179
+ | Retention | your per-segment policy (enforced via scheduled compaction / rolling windows) |
180
+ | Security measures | AES-256-GCM at rest, crypto-shred erasure, audit sink, your access controls |
181
+
182
+ ---
183
+
184
+ **See also:** the [getting-started guide](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/getting-started.md) (§9 encryption/crypto-shred, §10
185
+ metrics, §12 audit) and the [dashboards guide](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/dashboards.md).
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @cloudbitmaps/roaring
2
+
3
+ **Distributed, cloud-native Roaring Bitmaps.** Query and intersect billion-scale integer sets over tiered cloud
4
+ storage (RAM → NoSQL → object store) at a fraction of an always-on cache — with the fast, familiar in-memory API:
5
+ `add`, `has`, `remove`, `count`, `intersect`.
6
+
7
+ This is the **flagship flavor** of the [CloudBitmaps](https://github.com/cloudbitmaps/cloudbitmaps) family: the
8
+ roaring codec (CRoaring, via `roaring`) plus the `CloudRoaring` facade, on top of the codec-agnostic
9
+ [`@cloudbitmaps/core`](https://www.npmjs.com/package/@cloudbitmaps/core) engine — which arrives **transitively**,
10
+ so this is the only package you install.
11
+
12
+ ```bash
13
+ npm i @cloudbitmaps/roaring @aws-sdk/client-s3 @aws-sdk/client-dynamodb # + only the SDK(s) you use
14
+ ```
15
+
16
+ ```ts
17
+ import { CloudRoaring } from '@cloudbitmaps/roaring';
18
+ import { S3ColdDriver } from '@cloudbitmaps/roaring/s3';
19
+ import { DynamoDbWarmDriver } from '@cloudbitmaps/roaring/dynamodb';
20
+ ```
21
+
22
+ Every storage driver is re-exported on a matching subpath (`/s3`, `/gcs`, `/azure`, `/dynamodb`, `/postgres`,
23
+ `/redis`, `/mongodb`, `/cassandra`, `/mysql`); each backend SDK is an optional peer dependency, so the main entry
24
+ stays lean. Ships two CLIs: `compact-segments` and `export-segments`.
25
+
26
+ ## Measured, not modeled
27
+
28
+ Benchmarked against **real** S3 + DynamoDB in `us-east-1`, not an emulator: **$0.75 per million** incremental
29
+ writes, **$0.14 per million** `count()`s, **$5.88 per million** segment publishes — against an always-on Redis-HA
30
+ line of **$346/month, standing**. DynamoDB capacity is taken from AWS's own `ConsumedCapacity` rather than
31
+ estimated. `count()` on a published segment does **0 payload reads**, and intersecting two 2,000,000-id segments
32
+ fetches only the shared chunks.
33
+
34
+ The trade is stated plainly rather than buried: in-region, a RAM store answers a single membership check 10–20×
35
+ faster than a warm-tier round trip. If you need a sub-millisecond p99 on a working set that won't fit a bounded
36
+ hot cache, use Redis. If your sets are large, mostly read, and shouldn't cost $346/month to keep warm, use this.
37
+
38
+ Full README, guides, [benchmarks](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/benchmarks.md) (with
39
+ the method and what the numbers do *not* establish), and the design corpus live in the
40
+ [repository](https://github.com/cloudbitmaps/cloudbitmaps). Licensed Apache-2.0.
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var azure = require('@cloudbitmaps/core/azure');
4
+
5
+
6
+
7
+ Object.keys(azure).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return azure[k]; }
11
+ });
12
+ });
13
+ //# sourceMappingURL=index.cjs.map
14
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]}
@@ -0,0 +1,9 @@
1
+ export * from '@cloudbitmaps/core/azure';
2
+ import '@cloudbitmaps/core/cassandra';
3
+ import '@cloudbitmaps/core/dynamodb';
4
+ import '@cloudbitmaps/core/gcs';
5
+ import '@cloudbitmaps/core/mongodb';
6
+ import '@cloudbitmaps/core/mysql';
7
+ import '@cloudbitmaps/core/postgres';
8
+ import '@cloudbitmaps/core/redis';
9
+ import '@cloudbitmaps/core/s3';
@@ -0,0 +1,9 @@
1
+ export * from '@cloudbitmaps/core/azure';
2
+ import '@cloudbitmaps/core/cassandra';
3
+ import '@cloudbitmaps/core/dynamodb';
4
+ import '@cloudbitmaps/core/gcs';
5
+ import '@cloudbitmaps/core/mongodb';
6
+ import '@cloudbitmaps/core/mysql';
7
+ import '@cloudbitmaps/core/postgres';
8
+ import '@cloudbitmaps/core/redis';
9
+ import '@cloudbitmaps/core/s3';
@@ -0,0 +1,3 @@
1
+ export * from '@cloudbitmaps/core/azure';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ import { src_exports, runCompactionCycle } from '../chunk-JWCQLJUG.js';
3
+ import { hostname } from 'os';
4
+ import { join } from 'path';
5
+ import { pathToFileURL } from 'url';
6
+
7
+ function parseConfig(env) {
8
+ const root = env.CR_COMPACT_ROOT;
9
+ if (root === void 0 || root === "") {
10
+ throw new Error("CR_COMPACT_ROOT is required (the local-filesystem storage root)");
11
+ }
12
+ const mode = env.CR_COMPACT_MODE ?? "once";
13
+ if (mode !== "once" && mode !== "loop") {
14
+ throw new Error(`CR_COMPACT_MODE must be "once" or "loop"; got ${mode}`);
15
+ }
16
+ const num = (name, def) => {
17
+ const raw = env[name];
18
+ if (raw === void 0 || raw === "") return def;
19
+ const v = Number(raw);
20
+ if (!Number.isFinite(v) || v < 0)
21
+ throw new Error(`${name} must be a non-negative number; got ${raw}`);
22
+ return v;
23
+ };
24
+ const intOpt = (name, min = 0) => {
25
+ const raw = env[name];
26
+ if (raw === void 0 || raw === "") return void 0;
27
+ const v = Number(raw);
28
+ if (!Number.isInteger(v) || v < min)
29
+ throw new Error(`${name} must be an integer >= ${min}; got ${raw}`);
30
+ return v;
31
+ };
32
+ const shard = intOpt("CR_COMPACT_SHARD");
33
+ const totalShards = intOpt("CR_COMPACT_TOTAL_SHARDS");
34
+ if (shard === void 0 !== (totalShards === void 0)) {
35
+ throw new Error("set both CR_COMPACT_SHARD and CR_COMPACT_TOTAL_SHARDS, or neither");
36
+ }
37
+ return {
38
+ root,
39
+ mode,
40
+ intervalMs: num("CR_COMPACT_INTERVAL_MS", 3e4),
41
+ namespace: env.CR_COMPACT_NAMESPACE,
42
+ threshold: num("CR_COMPACT_THRESHOLD", 1),
43
+ keep: num("CR_COMPACT_KEEP", 1),
44
+ owner: env.CR_COMPACT_OWNER ?? `${hostname()}:${process.pid}`,
45
+ shard,
46
+ totalShards,
47
+ maxSegments: intOpt("CR_COMPACT_MAX_SEGMENTS", 1)
48
+ };
49
+ }
50
+ function localFsDeps(root, metrics) {
51
+ return {
52
+ cold: new src_exports.LocalFsColdDriver(join(root, "cold")),
53
+ warm: new src_exports.LocalFsWarmDriver(join(root, "warm")),
54
+ registry: new src_exports.LocalFsRegistryDriver(join(root, "registry")),
55
+ clock: { now: () => Date.now() },
56
+ // the bin is outside core/, so ambient time is allowed here
57
+ ...metrics ? { metrics } : {}
58
+ };
59
+ }
60
+ async function runOnce(deps, config) {
61
+ return runCompactionCycle(deps, {
62
+ owner: config.owner,
63
+ namespace: config.namespace,
64
+ threshold: config.threshold,
65
+ keep: config.keep,
66
+ shard: config.shard,
67
+ totalShards: config.totalShards,
68
+ maxSegments: config.maxSegments
69
+ });
70
+ }
71
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
72
+ var log = (obj) => {
73
+ process.stdout.write(`${JSON.stringify(obj)}
74
+ `);
75
+ };
76
+ function stdoutMetricsSink() {
77
+ return {
78
+ onEvent: (event) => log({ event: "metric", ...event })
79
+ };
80
+ }
81
+ async function main(env = process.env) {
82
+ const config = parseConfig(env);
83
+ const deps = localFsDeps(
84
+ config.root,
85
+ env.CR_COMPACT_METRICS === "1" ? stdoutMetricsSink() : void 0
86
+ );
87
+ if (config.mode === "once") {
88
+ const cycle = await runOnce(deps, config);
89
+ log({
90
+ event: "cycle",
91
+ mode: "once",
92
+ candidates: cycle.candidates,
93
+ compacted: cycle.compacted,
94
+ deferred: cycle.deferred,
95
+ results: cycle.results
96
+ });
97
+ return;
98
+ }
99
+ let stop = false;
100
+ const onSignal = () => {
101
+ stop = true;
102
+ };
103
+ process.on("SIGINT", onSignal);
104
+ process.on("SIGTERM", onSignal);
105
+ log({ event: "start", mode: "loop", intervalMs: config.intervalMs, owner: config.owner });
106
+ while (!stop) {
107
+ try {
108
+ const cycle = await runOnce(deps, config);
109
+ log({
110
+ event: "cycle",
111
+ candidates: cycle.candidates,
112
+ compacted: cycle.compacted,
113
+ deferred: cycle.deferred,
114
+ results: cycle.results
115
+ });
116
+ } catch (err) {
117
+ log({ event: "error", message: err.message });
118
+ }
119
+ if (!stop) await sleep(config.intervalMs);
120
+ }
121
+ log({ event: "stopped" });
122
+ }
123
+ if (process.argv[1] !== void 0 && import.meta.url === pathToFileURL(process.argv[1]).href) {
124
+ main().catch((err) => {
125
+ process.stderr.write(`${err.message}
126
+ `);
127
+ process.exit(1);
128
+ });
129
+ }
130
+
131
+ export { localFsDeps, main, parseConfig, runOnce };
132
+ //# sourceMappingURL=compact-segments.js.map
133
+ //# sourceMappingURL=compact-segments.js.map