@bjornpagen/bumbledb-log 1.2.0 → 1.2.1
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.
- package/README.md +48 -9
- package/pack-provenance.json +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Durable named application commands over
|
|
4
4
|
[Bumbledb](https://github.com/bjornpagen/bumbledb): a thin peer of
|
|
5
|
-
`@bjornpagen/bumbledb` (exact peer `1.2.
|
|
5
|
+
`@bjornpagen/bumbledb` (exact peer `1.2.1`). The package adds a durable
|
|
6
6
|
envelope around the exact core change/read machinery — it never duplicates
|
|
7
7
|
the engine surface. Core types (`ChangeSet`, `QueryReader`, `DbError`,
|
|
8
8
|
`StorageInspection`) are the peer's own exports.
|
|
@@ -44,12 +44,12 @@ The surface is small:
|
|
|
44
44
|
|
|
45
45
|
## Install
|
|
46
46
|
|
|
47
|
-
This guide follows the 1.2.
|
|
47
|
+
This guide follows the 1.2.1 source API. Use the guide from the Git tag matching
|
|
48
48
|
your installed package. GitHub release tarballs and npm publication are separate;
|
|
49
49
|
the npm command below applies once that version is published.
|
|
50
50
|
|
|
51
51
|
```sh
|
|
52
|
-
pnpm add @bjornpagen/bumbledb-log@1.2.
|
|
52
|
+
pnpm add @bjornpagen/bumbledb-log@1.2.1 @bjornpagen/bumbledb@1.2.1 effect@4.0.0-rc.112
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Quick start: one durable round trip
|
|
@@ -189,9 +189,10 @@ A later missing receipt is not proved loss.
|
|
|
189
189
|
## Backup and restore
|
|
190
190
|
|
|
191
191
|
```ts
|
|
192
|
-
import { NativeRuntime } from "@bjornpagen/bumbledb"
|
|
192
|
+
import { NativeRuntime, key, relation, schema, str, u64 } from "@bjornpagen/bumbledb"
|
|
193
193
|
import {
|
|
194
194
|
backup,
|
|
195
|
+
IncarnationId,
|
|
195
196
|
OperationId,
|
|
196
197
|
restore,
|
|
197
198
|
verifyBackup,
|
|
@@ -200,23 +201,57 @@ import {
|
|
|
200
201
|
import { Effect, Result } from "effect"
|
|
201
202
|
|
|
202
203
|
declare const binding: LocalBinding
|
|
204
|
+
// Ledger is the same declared schema used to create this history.
|
|
205
|
+
const Entry = relation("Entry", { id: u64, body: str })
|
|
206
|
+
const Ledger = schema("Ledger", { Entry }, [key(Entry, ["id"])])
|
|
203
207
|
|
|
204
208
|
const unwrap = <A, E>(result: Result.Result<A, E>): A => Result.getOrThrow(result)
|
|
205
209
|
|
|
206
210
|
const cycle = Effect.gen(function* () {
|
|
207
211
|
const operationId = unwrap(OperationId.parse("a1a1a1a1-a1a1-a1a1-a1a1-a1a1a1a1a1a1"))
|
|
208
212
|
const destination = { kind: "filesystem" as const, directory: "/tmp/ledger-backup" }
|
|
209
|
-
const backed = yield* backup(binding, { operationId, destination })
|
|
213
|
+
const backed = yield* backup(binding, { operationId, destination, schema: Ledger })
|
|
210
214
|
if (backed.kind !== "completed") {
|
|
211
215
|
return backed
|
|
212
216
|
}
|
|
213
|
-
yield* verifyBackup(destination, {})
|
|
214
|
-
|
|
217
|
+
yield* verifyBackup(destination, { backup: operationId })
|
|
218
|
+
const target: LocalBinding = {
|
|
219
|
+
...binding,
|
|
220
|
+
directory: "/tmp/restored-ledger",
|
|
221
|
+
identity: {
|
|
222
|
+
...binding.identity,
|
|
223
|
+
incarnationId: unwrap(IncarnationId.parse("b2b2b2b2-b2b2-b2b2-b2b2-b2b2b2b2b2b2"))
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return yield* restore(destination, target, {
|
|
227
|
+
operationId: unwrap(OperationId.parse("c3c3c3c3-c3c3-c3c3-c3c3-c3c3c3c3c3c3")),
|
|
228
|
+
backup: operationId,
|
|
229
|
+
schema: Ledger
|
|
230
|
+
})
|
|
215
231
|
})
|
|
216
232
|
void NativeRuntime.layer()
|
|
217
233
|
void cycle
|
|
218
234
|
```
|
|
219
235
|
|
|
236
|
+
Local and hosted histories produce the same independently verified backup
|
|
237
|
+
format. A local capture streams one coherent native snapshot; it never copies
|
|
238
|
+
live database files. The completion manifest is published last. Retry with the
|
|
239
|
+
same backup operation ID to resolve the original capture, including after the
|
|
240
|
+
source advances. A corrupt completed artifact refuses instead of being replaced.
|
|
241
|
+
|
|
242
|
+
Persist both operation IDs and the fresh target incarnation ID before dispatch;
|
|
243
|
+
the fixed IDs above are examples. Restore uses a separate operation ID, the
|
|
244
|
+
backup's operation ID, and a new incarnation with the same database/schema
|
|
245
|
+
identity. Adopt the completed restore's returned binding before opening it.
|
|
246
|
+
Providing `schema` also supports cold administrative opens when the source is
|
|
247
|
+
not already open in the runtime. Backup contains database facts and receipts;
|
|
248
|
+
external documents referenced by those facts need their own retention.
|
|
249
|
+
|
|
250
|
+
A completed writable restore retains its canonical genesis beside the native
|
|
251
|
+
activation. Repeating the same operation, target, and backup returns that
|
|
252
|
+
original result even if later commands changed the restored database. A different
|
|
253
|
+
operation or backup refuses without overwriting the target.
|
|
254
|
+
|
|
220
255
|
## Migrations
|
|
221
256
|
|
|
222
257
|
Schema evolution is generated, checked-in, inert data — never inferred at
|
|
@@ -242,7 +277,11 @@ runtime:
|
|
|
242
277
|
`migrationStatus`, `initialize`, `migrate`, `activateMigration`,
|
|
243
278
|
`abortMigration` — execute generated plans through the one native
|
|
244
279
|
executor, with `AdminOutcome` certainty (`completed` / `not-started` /
|
|
245
|
-
`outcome-unknown`).
|
|
280
|
+
`outcome-unknown`). Cold migration opens its source from the verified
|
|
281
|
+
generated snapshot chain; applications need not retain executable retired
|
|
282
|
+
schema modules. Published local targets use the standard tenant directory
|
|
283
|
+
containing `db/`. After activation, retrying the original migration returns
|
|
284
|
+
that target binding, so adopting a retry cannot reopen the frozen source.
|
|
246
285
|
|
|
247
286
|
**Current limitation:** these generated migration runner verbs target local
|
|
248
287
|
authorities only. The TypeScript/native bridge refuses hosted migration
|
|
@@ -258,6 +297,6 @@ runtime:
|
|
|
258
297
|
|
|
259
298
|
The native engine arrives through the peer `@bjornpagen/bumbledb`
|
|
260
299
|
(darwin-arm64, linux-arm64, linux-x64); this package ships TypeScript only
|
|
261
|
-
and declares both peers exactly (`@bjornpagen/bumbledb 1.2.
|
|
300
|
+
and declares both peers exactly (`@bjornpagen/bumbledb 1.2.1`, `effect
|
|
262
301
|
4.0.0-rc.112`). Version lockstep across the package family is enforced in
|
|
263
302
|
CI.
|
package/pack-provenance.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"candidateSourceDigest": "
|
|
2
|
+
"candidateSourceDigest": "ca9592096bd15b3f2a56e586a074505ae6695befdad7ed4df816af59a0ae1bf5",
|
|
3
3
|
"specificationRevision": "87e9a83ee21d1f843c73ac6e7057b2b740db75aae70a553b8053b4f38e87bd2d",
|
|
4
|
-
"stagedAt": "2026-09-
|
|
4
|
+
"stagedAt": "2026-09-11T13:37:06.952Z",
|
|
5
5
|
"package": "@bjornpagen/bumbledb-log",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.1"
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bjornpagen/bumbledb-log",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Durable named application commands over bumbledb: LocalHistory, HostedHistory, sealed commands with retained refs, published snapshots, one native TenantCache, and explicit maintenance/migration operations (Effect-only)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/bjornpagen/bumbledb#readme",
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@bjornpagen/bumbledb": "1.2.
|
|
52
|
+
"@bjornpagen/bumbledb": "1.2.1",
|
|
53
53
|
"effect": "4.0.0-rc.112"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|