@optimystic/db-core 1.0.0-beta.2 → 1.0.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.
- package/dist/src/cluster/structs.d.ts +62 -16
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +5 -3
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts +2 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts.map +1 -1
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js +10 -3
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js.map +1 -1
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/codec.js +8 -2
- package/dist/src/cohort-topic/wire/codec.js.map +1 -1
- package/dist/src/collection/collection.d.ts +467 -35
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +879 -149
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +109 -4
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +88 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collections/diary/diary.d.ts +6 -2
- package/dist/src/collections/diary/diary.d.ts.map +1 -1
- package/dist/src/collections/diary/diary.js +5 -2
- package/dist/src/collections/diary/diary.js.map +1 -1
- package/dist/src/collections/tree/struct.d.ts +192 -5
- package/dist/src/collections/tree/struct.d.ts.map +1 -1
- package/dist/src/collections/tree/struct.js +134 -0
- package/dist/src/collections/tree/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +13 -3
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +109 -6
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/logger-registry.d.ts +57 -0
- package/dist/src/logger-registry.d.ts.map +1 -0
- package/dist/src/logger-registry.js +168 -0
- package/dist/src/logger-registry.js.map +1 -0
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +3 -0
- package/dist/src/logger.js.map +1 -1
- package/dist/src/matchmaking/wire.d.ts.map +1 -1
- package/dist/src/matchmaking/wire.js +8 -2
- package/dist/src/matchmaking/wire.js.map +1 -1
- package/dist/src/network/durability.d.ts +45 -0
- package/dist/src/network/durability.d.ts.map +1 -0
- package/dist/src/network/durability.js +114 -0
- package/dist/src/network/durability.js.map +1 -0
- package/dist/src/network/i-key-network.d.ts +14 -6
- package/dist/src/network/i-key-network.d.ts.map +1 -1
- package/dist/src/network/index.d.ts +3 -0
- package/dist/src/network/index.d.ts.map +1 -1
- package/dist/src/network/index.js +3 -0
- package/dist/src/network/index.js.map +1 -1
- package/dist/src/network/lineage.d.ts +39 -0
- package/dist/src/network/lineage.d.ts.map +1 -0
- package/dist/src/network/lineage.js +61 -0
- package/dist/src/network/lineage.js.map +1 -0
- package/dist/src/network/routing-key.d.ts +24 -0
- package/dist/src/network/routing-key.d.ts.map +1 -0
- package/dist/src/network/routing-key.js +9 -0
- package/dist/src/network/routing-key.js.map +1 -0
- package/dist/src/network/stale-failure.d.ts +5 -1
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +5 -1
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +151 -8
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/reactivity/wire.d.ts.map +1 -1
- package/dist/src/reactivity/wire.js +8 -2
- package/dist/src/reactivity/wire.js.map +1 -1
- package/dist/src/testing/test-transactor.d.ts +64 -7
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +150 -23
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +141 -21
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +408 -122
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/errors.d.ts +39 -10
- package/dist/src/transaction/errors.d.ts.map +1 -1
- package/dist/src/transaction/errors.js +34 -9
- package/dist/src/transaction/errors.js.map +1 -1
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transactor/block-floors.d.ts +78 -0
- package/dist/src/transactor/block-floors.d.ts.map +1 -0
- package/dist/src/transactor/block-floors.js +62 -0
- package/dist/src/transactor/block-floors.js.map +1 -0
- package/dist/src/transactor/change-notifier.d.ts +43 -0
- package/dist/src/transactor/change-notifier.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.js +3 -0
- package/dist/src/transactor/change-notifier.js.map +1 -1
- package/dist/src/transactor/index.d.ts +1 -0
- package/dist/src/transactor/index.d.ts.map +1 -1
- package/dist/src/transactor/index.js +1 -0
- package/dist/src/transactor/index.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +43 -6
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +279 -81
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +94 -4
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +120 -42
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/transactor/transactor.d.ts +14 -1
- package/dist/src/transactor/transactor.d.ts.map +1 -1
- package/dist/src/transform/atomic.d.ts.map +1 -1
- package/dist/src/transform/atomic.js +12 -9
- package/dist/src/transform/atomic.js.map +1 -1
- package/dist/src/transform/base-pins.d.ts +50 -17
- package/dist/src/transform/base-pins.d.ts.map +1 -1
- package/dist/src/transform/base-pins.js +58 -11
- package/dist/src/transform/base-pins.js.map +1 -1
- package/dist/src/transform/cache-source.d.ts +75 -11
- package/dist/src/transform/cache-source.d.ts.map +1 -1
- package/dist/src/transform/cache-source.js +162 -36
- package/dist/src/transform/cache-source.js.map +1 -1
- package/dist/src/transform/digest.d.ts +8 -1
- package/dist/src/transform/digest.d.ts.map +1 -1
- package/dist/src/transform/digest.js +19 -9
- package/dist/src/transform/digest.js.map +1 -1
- package/dist/src/transform/helpers.d.ts +6 -2
- package/dist/src/transform/helpers.d.ts.map +1 -1
- package/dist/src/transform/helpers.js +8 -3
- package/dist/src/transform/helpers.js.map +1 -1
- package/dist/src/transform/tracker.d.ts +94 -14
- package/dist/src/transform/tracker.d.ts.map +1 -1
- package/dist/src/transform/tracker.js +222 -68
- package/dist/src/transform/tracker.js.map +1 -1
- package/dist/src/utility/structural-equals.d.ts +38 -0
- package/dist/src/utility/structural-equals.d.ts.map +1 -0
- package/dist/src/utility/structural-equals.js +77 -0
- package/dist/src/utility/structural-equals.js.map +1 -0
- package/package.json +2 -2
- package/src/cluster/structs.ts +298 -255
- package/src/cohort-topic/antidos/bootstrap-evidence-envelope.ts +260 -253
- package/src/cohort-topic/wire/codec.ts +222 -216
- package/src/collection/collection.ts +996 -158
- package/src/collection/struct.ts +99 -4
- package/src/collections/diary/diary.ts +71 -68
- package/src/collections/tree/struct.ts +248 -26
- package/src/collections/tree/tree.ts +130 -9
- package/src/index.ts +2 -1
- package/src/logger-registry.ts +224 -0
- package/src/logger.ts +4 -0
- package/src/matchmaking/wire.ts +8 -2
- package/src/network/durability.ts +123 -0
- package/src/network/i-key-network.ts +60 -52
- package/src/network/index.ts +10 -7
- package/src/network/lineage.ts +80 -0
- package/src/network/routing-key.ts +27 -0
- package/src/network/stale-failure.ts +5 -1
- package/src/network/struct.ts +156 -8
- package/src/reactivity/wire.ts +230 -224
- package/src/testing/test-transactor.ts +152 -24
- package/src/transaction/coordinator.ts +470 -131
- package/src/transaction/errors.ts +34 -9
- package/src/transaction/index.ts +1 -0
- package/src/transactor/block-floors.ts +105 -0
- package/src/transactor/change-notifier.ts +129 -80
- package/src/transactor/index.ts +1 -0
- package/src/transactor/network-transactor.ts +297 -84
- package/src/transactor/transactor-source.ts +131 -42
- package/src/transactor/transactor.ts +13 -1
- package/src/transform/atomic.ts +25 -22
- package/src/transform/base-pins.ts +76 -18
- package/src/transform/cache-source.ts +327 -194
- package/src/transform/digest.ts +21 -10
- package/src/transform/helpers.ts +8 -3
- package/src/transform/tracker.ts +423 -270
- package/src/utility/structural-equals.ts +72 -0
- package/dist/src/utility/block-id-to-bytes.d.ts +0 -3
- package/dist/src/utility/block-id-to-bytes.d.ts.map +0 -1
- package/dist/src/utility/block-id-to-bytes.js +0 -7
- package/dist/src/utility/block-id-to-bytes.js.map +0 -1
- package/src/utility/block-id-to-bytes.ts +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PeerId } from "../network/types.js";
|
|
2
|
-
import type { ActionTransforms, ActionBlocks, BlockActionStatus, ITransactor, IKeyNetwork, BlockId, GetBlockResults, PendResult, CommitResult, PendRequest, IRepo, BlockGets, CommitRequest, ClusterNomineesResult, CollectionId } from "../index.js";
|
|
2
|
+
import type { ActionTransforms, ActionBlocks, ActionLineage, BlockActionStatus, ITransactor, IKeyNetwork, BlockId, GetBlockResults, PendResult, CommitResult, PendRequest, IRepo, BlockGets, CommitRequest, ClusterNomineesResult, CollectionId } from "../index.js";
|
|
3
3
|
import type { IBlockChangeNotifier, CollectionChangeListener } from "./change-notifier.js";
|
|
4
4
|
type NetworkTransactorInit = {
|
|
5
5
|
timeoutMs: number;
|
|
@@ -23,6 +23,17 @@ type NetworkTransactorInit = {
|
|
|
23
23
|
* absent, `onCollectionChange` is a logged no-op.
|
|
24
24
|
*/
|
|
25
25
|
localChangeNotifier?: IBlockChangeNotifier;
|
|
26
|
+
/**
|
|
27
|
+
* The peer id of the node this transactor runs on, when `getRepo` hands that id the node's own
|
|
28
|
+
* co-located repo rather than a network client — the same "co-located node" idea as
|
|
29
|
+
* `localChangeNotifier`. It only breaks ties when a pend's blocks are grouped onto coordinators:
|
|
30
|
+
* among cohort members covering equally many blocks, this node wins, so a write it is responsible
|
|
31
|
+
* for is coordinated without a network hop. It never wins over a member covering more blocks
|
|
32
|
+
* (fewer batches come first), and it never makes this node a coordinator for a block whose cohort
|
|
33
|
+
* does not include it. Omit when nothing is co-located; ties then go to the member seen first,
|
|
34
|
+
* which is the nearest.
|
|
35
|
+
*/
|
|
36
|
+
localPeerId?: PeerId;
|
|
26
37
|
};
|
|
27
38
|
export declare class NetworkTransactor implements ITransactor, IBlockChangeNotifier {
|
|
28
39
|
private readonly keyNetwork;
|
|
@@ -31,6 +42,8 @@ export declare class NetworkTransactor implements ITransactor, IBlockChangeNotif
|
|
|
31
42
|
private readonly dialTimeoutMs;
|
|
32
43
|
private readonly getRepo;
|
|
33
44
|
private readonly localChangeNotifier;
|
|
45
|
+
/** `NetworkTransactorInit.localPeerId` as a string, the form cohort peer ids arrive in. */
|
|
46
|
+
private readonly localPeerId;
|
|
34
47
|
/**
|
|
35
48
|
* Per-transaction coordinator cache: `actionId → (blockId → resolved coordinator)`.
|
|
36
49
|
* {@link pend} populates it from its final (retry-adjusted) batch assignment; commit
|
|
@@ -75,6 +88,26 @@ export declare class NetworkTransactor implements ITransactor, IBlockChangeNotif
|
|
|
75
88
|
private refineInvalidatedStatuses;
|
|
76
89
|
/** Whether `actionId` has a durable invalidation entry in `collectionId`'s log (opened once, cached). */
|
|
77
90
|
private hasDurableInvalidation;
|
|
91
|
+
/**
|
|
92
|
+
* See {@link ITransactor.getLineage}. Asks EVERY member of each block's cohort, directly, and
|
|
93
|
+
* folds their answers with {@link judgeCohortLineage} — not the coordinator round {@link get}
|
|
94
|
+
* runs, because no single member can answer for the cohort: a member that took a later revision
|
|
95
|
+
* as a replica cannot say what it was built from, while the member it came from can.
|
|
96
|
+
*
|
|
97
|
+
* The per-member `get` carries no context, so it pins nothing and promotes nothing; asking is
|
|
98
|
+
* never what makes a write land.
|
|
99
|
+
*
|
|
100
|
+
* NOTE: one request per cohort member per block. Reached only when a writer's own half-landed
|
|
101
|
+
* write was refused as superseded, which is rare, so the fan-out is not batched by member. If a
|
|
102
|
+
* write path ever calls this routinely, group the blocks a member is in the cohort of into one
|
|
103
|
+
* request per member.
|
|
104
|
+
*/
|
|
105
|
+
getLineage(ref: ActionBlocks & {
|
|
106
|
+
rev: number;
|
|
107
|
+
}): Promise<ActionLineage>;
|
|
108
|
+
/** One block's cohort answer: every member asked in parallel, a member that cannot be reached
|
|
109
|
+
* (or whose cohort cannot be resolved at all) counted as `unknown` rather than left out. */
|
|
110
|
+
private cohortLineage;
|
|
78
111
|
private consolidateCoordinators;
|
|
79
112
|
pend(blockAction: PendRequest): Promise<PendResult>;
|
|
80
113
|
/**
|
|
@@ -120,6 +153,9 @@ export declare class NetworkTransactor implements ITransactor, IBlockChangeNotif
|
|
|
120
153
|
* `debt-unpromotable-pending-records-need-a-sweep`); and this covers only the sweep's abandonment
|
|
121
154
|
* — `StorageRepo.commit`'s genuine-fault arm deliberately KEEPS a failed batch's pendings for a
|
|
122
155
|
* retry, so it is a second producer of the same durable state whenever that retry never comes.
|
|
156
|
+
*
|
|
157
|
+
* @returns the abandoned block ids — exactly the set cancelled here — so {@link commit} can name
|
|
158
|
+
* them as `torn` on the acknowledgement without re-deriving the set by a second rule.
|
|
123
159
|
*/
|
|
124
160
|
private cancelAbandonedSweepBlocks;
|
|
125
161
|
private commitBlock;
|
|
@@ -130,11 +166,12 @@ export declare class NetworkTransactor implements ITransactor, IBlockChangeNotif
|
|
|
130
166
|
* both must distinguish a confirmed conflict (return it; the caller cancels and re-drives) from
|
|
131
167
|
* a transient fault (throw / tolerate).
|
|
132
168
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* `
|
|
136
|
-
*
|
|
137
|
-
*
|
|
169
|
+
* Rebuilt the same way {@link pend}'s aggregate is: `reason` is the first one any batch gave
|
|
170
|
+
* (the only diagnostic that survives into the coordinator's error text — a refusal whose reason
|
|
171
|
+
* is `commit-not-durable` must not read as "stale commit", a rival's win), `conflict` holds when
|
|
172
|
+
* any batch was a classified conflict, and `staleAt` is the highest confirmed revision. A
|
|
173
|
+
* reason-only StaleFailure (success:false, no `missing`) lands here too and comes out with
|
|
174
|
+
* `missing: []` and its reason intact.
|
|
138
175
|
*/
|
|
139
176
|
private staleFromBatches;
|
|
140
177
|
/** Attempts to commit a set of blocks, and handles failures and errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-transactor.d.ts","sourceRoot":"","sources":["../../../src/transactor/network-transactor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"network-transactor.d.ts","sourceRoot":"","sources":["../../../src/transactor/network-transactor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAKlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAA4C,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAc,aAAa,EAA+B,qBAAqB,EAAE,YAAY,EAA0H,MAAM,aAAa,CAAC;AAChd,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAgB3F,KAAK,qBAAqB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C;;;;;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