@cloudbitmaps/core 0.20.0 → 0.22.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 (77) hide show
  1. package/README.md +101 -5
  2. package/dist/{chunk-YSC7NJWV.js → chunk-OSU7W2Y3.js} +811 -164
  3. package/dist/chunk-OSU7W2Y3.js.map +7 -0
  4. package/dist/core/audit.d.ts +12 -2
  5. package/dist/core/bit-route.d.ts +9 -1
  6. package/dist/core/blob.d.ts +12 -1
  7. package/dist/core/codec.d.ts +1 -1
  8. package/dist/core/combine-expr.d.ts +10 -8
  9. package/dist/core/combine-feed.d.ts +12 -18
  10. package/dist/core/combine-many.d.ts +29 -22
  11. package/dist/core/concurrency.d.ts +8 -0
  12. package/dist/core/consistency.d.ts +69 -17
  13. package/dist/core/crbm/reader.d.ts +52 -6
  14. package/dist/core/crbm-storage-source.d.ts +65 -452
  15. package/dist/core/crypto.d.ts +6 -1
  16. package/dist/core/determinism.d.ts +2 -1
  17. package/dist/core/engine.d.ts +222 -33
  18. package/dist/core/erase-id.d.ts +60 -15
  19. package/dist/core/erasure.d.ts +5 -4
  20. package/dist/core/errors.d.ts +61 -11
  21. package/dist/core/leases.d.ts +4 -3
  22. package/dist/core/load.d.ts +58 -45
  23. package/dist/core/lru.d.ts +2 -15
  24. package/dist/core/metrics.d.ts +5 -3
  25. package/dist/core/pinned-storage-source.d.ts +4 -4
  26. package/dist/core/ports.d.ts +96 -22
  27. package/dist/core/registry-scan.d.ts +0 -7
  28. package/dist/core/retention-sweep.d.ts +70 -66
  29. package/dist/core/retention.d.ts +2 -2
  30. package/dist/core/retry.d.ts +15 -18
  31. package/dist/core/rollback.d.ts +61 -31
  32. package/dist/core/validate.d.ts +2 -0
  33. package/dist/driver-kit.d.ts +11 -2
  34. package/dist/driver-kit.js +84 -16
  35. package/dist/driver-kit.js.map +3 -3
  36. package/dist/drivers/_shared/bytes.d.ts +6 -0
  37. package/dist/drivers/_shared/faults.d.ts +15 -0
  38. package/dist/drivers/_shared/object-keys.d.ts +18 -0
  39. package/dist/drivers/_shared/object-registry-keys.d.ts +0 -2
  40. package/dist/drivers/_shared/object-registry.d.ts +2 -0
  41. package/dist/drivers/_shared/options.d.ts +19 -0
  42. package/dist/drivers/backends.d.ts +2 -0
  43. package/dist/drivers/crypto.d.ts +1 -1
  44. package/dist/export/index.d.ts +9 -8
  45. package/dist/index.d.ts +11 -10
  46. package/dist/index.js +4202 -2833
  47. package/dist/index.js.map +4 -4
  48. package/package.json +7 -2
  49. package/dist/chunk-YSC7NJWV.js.map +0 -7
  50. package/dist/core/chunk-checks.d.ts +0 -34
  51. package/dist/core/chunk-stream.d.ts +0 -22
  52. package/dist/core/chunk-window.d.ts +0 -30
  53. package/dist/core/combine-ledger.d.ts +0 -43
  54. package/dist/core/crbm/crc32c.d.ts +0 -10
  55. package/dist/core/crbm/fingerprint.d.ts +0 -18
  56. package/dist/core/crbm/format.d.ts +0 -151
  57. package/dist/core/crbm/frame.d.ts +0 -10
  58. package/dist/core/crbm/plan-reads.d.ts +0 -44
  59. package/dist/core/crbm/varint.d.ts +0 -13
  60. package/dist/core/crbm/writer.d.ts +0 -68
  61. package/dist/core/due-index.d.ts +0 -53
  62. package/dist/core/generation-gc.d.ts +0 -179
  63. package/dist/core/item-pull.d.ts +0 -29
  64. package/dist/core/kept-generations.d.ts +0 -40
  65. package/dist/core/metadata.d.ts +0 -42
  66. package/dist/core/reader-defaults.d.ts +0 -29
  67. package/dist/core/summary.d.ts +0 -78
  68. package/dist/core/token.d.ts +0 -41
  69. package/dist/drivers/_shared/entropy.d.ts +0 -5
  70. package/dist/drivers/_shared/registry.d.ts +0 -104
  71. package/dist/drivers/localfs/exact-case.d.ts +0 -37
  72. package/dist/drivers/localfs/fs-util.d.ts +0 -33
  73. package/dist/drivers/localfs/paths.d.ts +0 -40
  74. package/dist/drivers/localfs/registry.d.ts +0 -44
  75. package/dist/drivers/localfs/storage.d.ts +0 -21
  76. package/dist/drivers/memory.d.ts +0 -61
  77. package/dist/testing/fuzz-core.d.ts +0 -15
package/README.md CHANGED
@@ -7,9 +7,18 @@ when you install the two packages you want. Install those instead:
7
7
  pnpm add @cloudbitmaps/roaring @cloudbitmaps/s3 # the store, and the storage you have (or /gcs, or /azure-blob)
8
8
  ```
9
9
 
10
- On npm 12 and pnpm 10 and later, allow `roaring`'s one install script first, or the install exits 0 and the package throws at `import`. Put this in your `package.json`: `{ "allowScripts": { "roaring": true }, "pnpm": { "onlyBuiltDependencies": ["roaring"] } }`. npm 11 runs the script but warns until you allow it the same way; pnpm 9 needs nothing extra. [Details](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/getting-started.md#cannot-find-module-buildreleaseroaringnode-after-a-successful-install).
10
+ `roaring` needs its one install script to fetch its native binary, and newer clients run a dependency's script only if you allow it. Allow it before you install:
11
11
 
12
- Depend on `@cloudbitmaps/core` directly only to write a flavor or a driver.
12
+ - **npm 12:** add `{ "allowScripts": { "roaring": true } }` to your `package.json`. Without it the install exits 0 and the package throws at `import`. npm 11 runs the script but warns until you allow it the same way.
13
+ - **pnpm 11 and later:** put `allowBuilds: { roaring: true }` in a `pnpm-workspace.yaml` beside your `package.json`. Those versions no longer read the `package.json` `pnpm` key. Without it the install exits 1 with `ERR_PNPM_IGNORED_BUILDS`.
14
+ - **pnpm 10:** add `{ "pnpm": { "onlyBuiltDependencies": ["roaring"] } }` to your `package.json`. Without it the install exits 0 and the package throws at `import`.
15
+ - **pnpm 9:** nothing extra.
16
+
17
+ [Details](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/getting-started.md#cannot-find-module-buildreleaseroaringnode-after-a-successful-install).
18
+
19
+ Depend on `@cloudbitmaps/core` directly only to write a driver, through `@cloudbitmaps/core/driver-kit`.
20
+
21
+ > **The main entry of this package is internal.** It is the engine `@cloudbitmaps/roaring` and the driver packages are built on, and it is outside the stability promise: it can change in any minor release, and a change to it gets no CHANGELOG Breaking entry. Install `@cloudbitmaps/roaring` and a driver. The public entry here is `@cloudbitmaps/core/driver-kit`, the contract for writing a driver.
13
22
 
14
23
  > **ESM-only, Node ≥ 22.12.** Use `import`; for `require()`, Jest and TypeScript, see
15
24
  > [CommonJS, Jest and TypeScript](https://github.com/cloudbitmaps/cloudbitmaps/blob/main/docs/guide/getting-started.md#commonjs-jest-and-typescript).
@@ -24,9 +33,96 @@ and crypto-shred, erasure by rewrite, retention, and the in-memory and local-fil
24
33
  dependencies and no cloud SDK**. The cloud backends are their own packages, built against
25
34
  `@cloudbitmaps/core/driver-kit`, the declared contract a driver depends on. A third-party driver can use it too.
26
35
 
27
- Its main entry is the flavor-author kit: the read engine, the standalone forms of the store's methods (`loadSegment`,
28
- `dropSegment`, `retireExpired` and the rest), and the retry and budget internals. `@cloudbitmaps/roaring` re-exports,
29
- by name, what an application uses.
36
+ Its main entry is the internal engine (the read engine, the standalone forms of the store's methods, and the retry and
37
+ budget internals) that `@cloudbitmaps/roaring` and the driver packages import; it is not a public API. What an
38
+ application uses is re-exported, by name, from `@cloudbitmaps/roaring`. The driver contracts (the storage and registry
39
+ ports, the registry's record types, the read-source and keystore ports) are exported by `@cloudbitmaps/core/driver-kit`
40
+ alone, which is complete: every type its signatures name is exported there too.
41
+
42
+ ## How the storage path is laid out
43
+
44
+ The `.crbm` storage path lives in `src/core/`, one module per concern. Arrows read "imports":
45
+
46
+ ```
47
+ bulk-load.ts write path: ids in, a generation written and published
48
+ / | \
49
+ v v v
50
+ publish.ts crbm-write.ts crbm-open.ts <---- crbm-storage-source.ts read path
51
+ ```
52
+
53
+ `publish.ts`, `crbm-write.ts` and `crbm-open.ts` import none of the others. Outside this group, `load.ts` imports
54
+ `bulk-load.ts`, `publish.ts` and `crbm-open.ts`; `erase-id.ts` imports `publish.ts`, `crbm-write.ts` and
55
+ `crbm-open.ts`; `rollback.ts` and `consistency.ts` import `crbm-open.ts`. `combine-many.ts`, `pinned-storage-source.ts`
56
+ (types only) and the package entry import `crbm-storage-source.ts`.
57
+
58
+ | File | Holds |
59
+ |---|---|
60
+ | `crbm-write.ts` | writing one immutable generation from in-memory bitmaps, from a stream or from already-encoded chunks |
61
+ | `publish.ts` | the forward-only pointer advance every write ends with, the lease patch, the refusal to point a keyed row at a cleartext generation, and the settling of a registry write that got no answer |
62
+ | `bulk-load.ts` | the loader `load()` is built on, with its read-ahead: ids, a decoded bitmap or a combine's chunks in, made into chunks (ids bucketed, a bitmap split by its codec where the codec can, a combine's chunks checked), one generation written, and published when a registry is wired and the caller does not defer it; `load()` defers it and publishes through `publish.ts` after its guard |
63
+ | `known-generations.ts` | the row's ledger, `knownGens`: what a usable one is, the window a load collects by name, the cap, and the ledger a publish and a rollback write |
64
+ | `ledger-seed.ts` | the first window of a ledger over a row that has none, read from the bucket |
65
+ | `crbm-open.ts` | opening a stored generation without the cache: the blob reader over a driver object, the checked and noting opens, the identity checks that tie an open to the object it read, generation verification, and the rollback target open |
66
+ | `crbm-storage-source.ts` | the read path: `CrbmStorageChunkSource`, its resolution cache and the pin machinery |
67
+
68
+ No write-path module imports `crbm-storage-source.ts`, and it imports only `crbm-open.ts` of the other four.
69
+
70
+ ## The row's ledger of generations
71
+
72
+ A registry row carries `knownGens`: the generations the segment knows and has not decided to delete, each with the
73
+ CRC32C its object's footer stores, the current one last. They are the ones it made current, in that order, and, when a
74
+ publish over a row with no usable ledger seeds one, the ones a count by `keep` keeps in the bucket, which can include an
75
+ object no load published (an orphan or a stray): an entry says the library knows the generation and its checksum, not
76
+ that a load published it. Its entries below the
77
+ pointer are the window a load keeps and the generations a live lease holds, so a load deletes what its publish pushed out
78
+ of the window by name and lists the bucket only when it cannot rely on the row.
79
+
80
+ ```
81
+ row (schema 5) bucket
82
+ currentGen: 7 segment.3.crbm segment.5.crbm segment.6.crbm segment.7.crbm
83
+ knownGens: [ {5,crcA}, {6,crcB}, {7,crcC} ] | | | |
84
+ \_____ window ____/ \ current deleted by in the window in the window current
85
+ name when a
86
+ load pushed it out
87
+ ```
88
+
89
+ - **A publish writes it** in the compare-and-swap that moves the pointer. Over a row whose ledger is usable, the window
90
+ is drawn from the order the generations were made current: the `keep` most recently current of the entries numbered
91
+ below the new generation (at most 127), beside them every entry a live lease holds, whatever `keep` says, then the
92
+ entries a rollback left numbered above the new generation (carried while the ledger holds fewer than 128, never
93
+ collected, and taking no place in `keep`), then the new generation. The generation the publish superseded is the
94
+ ledger's last entry, so it comes first, and after a rollback the restored generation ranks ahead of the ones the
95
+ rollback moved away from, from every load on. Over a row with no usable ledger (a hand repair, a restore, a pointer
96
+ moved down by hand) the load lists the bucket and writes the window a count by `keep` keeps there: the generation the
97
+ row named as current first, then the newest by number, each with a footer read (read eight at a time under the store's
98
+ read retry, the superseded generation's too; a clear summary that describes it with another checksum leaves it out),
99
+ and beside them the listed generations a live lease holds wherever they are numbered (the leases read from the row
100
+ once more just before the write, one more row read), oldest first by number with the leased ones before the window and
101
+ the superseded one last, then the new generation. A generation gone from the bucket, or whose footer fails its checks,
102
+ is left out. The publish then collects by that count.
103
+ - **An incarnation's first publish writes the new generation alone** (no row, or a row with no pointer): nothing below
104
+ it was made current by it, so a seed could only name objects no load of it published.
105
+ - **A usable ledger is never started again**: over one a run of publishes with a larger `keep` carried past 64 names
106
+ that no lease holds, the next load with a `keep` of 64 or less writes the window it draws from the ledger's order, the
107
+ leased entries and those above its number, and collects by listing.
108
+ - **A collection reads it.** A load with a `keep` of at most 64 deletes by name the entries its publish left out. A pass
109
+ that keeps by a count (a `keep` above 64, a ledger naming more than 64 below the pointer that no lease holds, or the
110
+ first load over a row with no usable ledger) keeps the ledger's own most recently current names first, then the newest
111
+ others by number, `keep` in all, and spares every name the row knows when it reads the row again before a delete.
112
+ - **A rollback carries it**, moving its target to the end with the checksum of the footer it read, keeping every
113
+ generation the row's leases name when it trims a full ledger, and writes none over a row that had none: a rollback
114
+ never starts a ledger.
115
+ - **An erasure's rewrite leaves itself alone in it**, since it deletes every older generation; a shred removes it. An
116
+ erasure that does not rewrite takes each generation it will delete out of the ledger first, in one write made after
117
+ its search and before its first delete, only when the ledger names one (`erase-id.ts`'s fence); its collections then
118
+ spare every generation the row names when they read the row before a delete.
119
+ - **Caps**: a writer writes at most 192 entries and keeps an entry nothing protects only while the ledger holds fewer
120
+ than 128; the registry accepts 192 written and 384 read, so no publish or rollback is refused for the ledger's size.
121
+ - **Errors**: a malformed ledger is `ValidationError` on a write and `IntegrityError` on a read; a ledger that disagrees
122
+ with its row is read and not used; a row stamped 4 or lower is `UnsupportedError`.
123
+ - **A rollback reads it**: it moves only onto a generation the ledger names, whose object's footer checksum is the one
124
+ recorded, unless the caller passes `allowUnknown`; where the pointer alone decides (a row with no usable ledger, a
125
+ number below a full ledger's bound) a target below the pointer needs no flag. `rollback.ts` holds the rule.
30
126
 
31
127
  ## Documentation
32
128