@optimystic/db-core 1.11.0 → 1.12.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 +13 -0
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/store.d.ts +8 -1
- package/dist/src/cohort-topic/registration/store.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/store.js +57 -0
- package/dist/src/cohort-topic/registration/store.js.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.d.ts +5 -0
- package/dist/src/cohort-topic/wire/primitives.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.js +5 -0
- package/dist/src/cohort-topic/wire/primitives.js.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +1 -3
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/collection/action.d.ts +15 -1
- package/dist/src/collection/action.d.ts.map +1 -1
- package/dist/src/collection/action.js.map +1 -1
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +40 -4
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/struct.d.ts +6 -2
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/matchmaking/arrival-push.d.ts +35 -0
- package/dist/src/matchmaking/arrival-push.d.ts.map +1 -0
- package/dist/src/matchmaking/arrival-push.js +56 -0
- package/dist/src/matchmaking/arrival-push.js.map +1 -0
- package/dist/src/matchmaking/config.d.ts +12 -2
- package/dist/src/matchmaking/config.d.ts.map +1 -1
- package/dist/src/matchmaking/config.js +8 -2
- package/dist/src/matchmaking/config.js.map +1 -1
- package/dist/src/matchmaking/index.d.ts +3 -2
- package/dist/src/matchmaking/index.d.ts.map +1 -1
- package/dist/src/matchmaking/index.js +3 -2
- package/dist/src/matchmaking/index.js.map +1 -1
- package/dist/src/matchmaking/seeker.d.ts +5 -2
- package/dist/src/matchmaking/seeker.d.ts.map +1 -1
- package/dist/src/matchmaking/seeker.js +6 -1
- package/dist/src/matchmaking/seeker.js.map +1 -1
- package/dist/src/matchmaking/wire.d.ts +66 -3
- package/dist/src/matchmaking/wire.d.ts.map +1 -1
- package/dist/src/matchmaking/wire.js +79 -11
- package/dist/src/matchmaking/wire.js.map +1 -1
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +28 -46
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -1
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +27 -0
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/transaction.js +27 -0
- package/dist/src/transaction/transaction.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +6 -2
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/package.json +1 -1
- package/src/cluster/structs.ts +13 -0
- package/src/cohort-topic/registration/store.ts +68 -0
- package/src/cohort-topic/wire/primitives.ts +6 -0
- package/src/cohort-topic/wire/validate.ts +1 -3
- package/src/collection/action.ts +15 -1
- package/src/collection/collection.ts +43 -4
- package/src/collection/struct.ts +6 -2
- package/src/matchmaking/arrival-push.ts +66 -0
- package/src/matchmaking/config.ts +17 -2
- package/src/matchmaking/index.ts +3 -2
- package/src/matchmaking/seeker.ts +11 -3
- package/src/matchmaking/wire.ts +134 -10
- package/src/testing/test-transactor.ts +28 -40
- package/src/transaction/index.ts +2 -1
- package/src/transaction/transaction.ts +28 -0
- package/src/transactor/transactor-source.ts +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACN,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,aAAa,EACb,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACN,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,aAAa,EACb,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,sBAAsB,CAAC"}
|
|
@@ -120,6 +120,33 @@ export declare const MaxPriority = 8;
|
|
|
120
120
|
* cannot exceed the cap.
|
|
121
121
|
*/
|
|
122
122
|
export declare function clampPriority(priority: number | undefined): number;
|
|
123
|
+
/**
|
|
124
|
+
* How many times a storage member must ITSELF have refused one action's pend as stale — a rival's
|
|
125
|
+
* revision already committed under the requested one — before it holds the next slot of that pend's
|
|
126
|
+
* blocks for the action. Counted per action id, which is one sync cycle (`Collection.syncInternal`
|
|
127
|
+
* mints the id once and every attempt of that cycle reuses it), so the count is "losses in a row of
|
|
128
|
+
* one write" and never needs resetting.
|
|
129
|
+
*
|
|
130
|
+
* What the member holds, and how it answers a rival while it holds, is in db-p2p's
|
|
131
|
+
* `ClusterMember.validatePendOperations` (`cluster/cluster-repo.ts`): the hold answers the next
|
|
132
|
+
* other-action pend of each block with the same `held` vote a storage reservation produces, once,
|
|
133
|
+
* for a bounded window, and is consumed by the aged action's own next pend. It closes the
|
|
134
|
+
* sequential starvation the aged {@link Transaction.priority} cannot reach — a stream of quick
|
|
135
|
+
* writers that each commit and leave before the slow one's attempt arrives never co-pend with it,
|
|
136
|
+
* so `resolveRace` never meets them (docs/correctness.md Theorem 9, "Bound").
|
|
137
|
+
*
|
|
138
|
+
* The count is the member's own and never the self-asserted priority: a member grants only on
|
|
139
|
+
* refusals it issued, so no claimant can talk it into a hold with a number. The writer side counts the
|
|
140
|
+
* refusals that confirmed a committed revision against the same constant to stop backing off on the
|
|
141
|
+
* loss after which a member holds for it (`retryBackoffMs` in `collection/collection.ts`), so the two
|
|
142
|
+
* sides agree with nothing on the wire — wherever the refused pends reached the member.
|
|
143
|
+
*
|
|
144
|
+
* Three: the plan-stage measurement (ticket `slot-hold-for-an-aged-writer`) showed an honest slow
|
|
145
|
+
* writer behind a quick stream losing nine of ten attempts, so two losses are an ordinary lost race
|
|
146
|
+
* and three are the stream. Lower, and a single lost race would hold a block against every other
|
|
147
|
+
* writer; higher, and the slow writer pays more refused round trips before it is helped.
|
|
148
|
+
*/
|
|
149
|
+
export declare const SlotHoldAfterLosses = 3;
|
|
123
150
|
/** Check whether a transaction stamp has expired. */
|
|
124
151
|
export declare function isTransactionExpired(stamp: TransactionStamp): boolean;
|
|
125
152
|
/** The stamp fields that feed the id hash (everything except the id itself). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAElB,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IAEnB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd,qFAAqF;IACrF,EAAE,EAAE,MAAM,CAAC;CACX,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,iDAAiD;IACjD,KAAK,EAAE,gBAAgB,CAAC;IAExB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IAErB,2DAA2D;IAC3D,KAAK,EAAE,cAAc,EAAE,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,EAAE,MAAM,C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;;;;;;;;;;;;;;;;OAgBG;IACH,oBAAoB,CAAC,EAAE,YAAY,EAAE,CAAC;IACtC,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAElF;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,iBAAiB,EAAE,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,mCAAmC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEtF;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC7D"}
|
|
@@ -29,6 +29,33 @@ export function clampPriority(priority) {
|
|
|
29
29
|
}
|
|
30
30
|
return Math.floor(priority);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* How many times a storage member must ITSELF have refused one action's pend as stale — a rival's
|
|
34
|
+
* revision already committed under the requested one — before it holds the next slot of that pend's
|
|
35
|
+
* blocks for the action. Counted per action id, which is one sync cycle (`Collection.syncInternal`
|
|
36
|
+
* mints the id once and every attempt of that cycle reuses it), so the count is "losses in a row of
|
|
37
|
+
* one write" and never needs resetting.
|
|
38
|
+
*
|
|
39
|
+
* What the member holds, and how it answers a rival while it holds, is in db-p2p's
|
|
40
|
+
* `ClusterMember.validatePendOperations` (`cluster/cluster-repo.ts`): the hold answers the next
|
|
41
|
+
* other-action pend of each block with the same `held` vote a storage reservation produces, once,
|
|
42
|
+
* for a bounded window, and is consumed by the aged action's own next pend. It closes the
|
|
43
|
+
* sequential starvation the aged {@link Transaction.priority} cannot reach — a stream of quick
|
|
44
|
+
* writers that each commit and leave before the slow one's attempt arrives never co-pend with it,
|
|
45
|
+
* so `resolveRace` never meets them (docs/correctness.md Theorem 9, "Bound").
|
|
46
|
+
*
|
|
47
|
+
* The count is the member's own and never the self-asserted priority: a member grants only on
|
|
48
|
+
* refusals it issued, so no claimant can talk it into a hold with a number. The writer side counts the
|
|
49
|
+
* refusals that confirmed a committed revision against the same constant to stop backing off on the
|
|
50
|
+
* loss after which a member holds for it (`retryBackoffMs` in `collection/collection.ts`), so the two
|
|
51
|
+
* sides agree with nothing on the wire — wherever the refused pends reached the member.
|
|
52
|
+
*
|
|
53
|
+
* Three: the plan-stage measurement (ticket `slot-hold-for-an-aged-writer`) showed an honest slow
|
|
54
|
+
* writer behind a quick stream losing nine of ten attempts, so two losses are an ordinary lost race
|
|
55
|
+
* and three are the stream. Lower, and a single lost race would hold a block against every other
|
|
56
|
+
* writer; higher, and the slow writer pays more refused round trips before it is helped.
|
|
57
|
+
*/
|
|
58
|
+
export const SlotHoldAfterLosses = 3;
|
|
32
59
|
/** Check whether a transaction stamp has expired. */
|
|
33
60
|
export function isTransactionExpired(stamp) {
|
|
34
61
|
return Date.now() > stamp.expiration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/transaction/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,w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,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,SAAI,EAAE,YAAY,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA0C7M;;;;;;;;;;OAUG;YACW,aAAa;CAS3B"}
|
|
@@ -118,8 +118,12 @@ export class TransactorSource {
|
|
|
118
118
|
this.readRevisions.set(id, rev);
|
|
119
119
|
this.served.set(block, { rev, mayRetain: this.mayRetain(id, rev) });
|
|
120
120
|
}
|
|
121
|
-
//
|
|
122
|
-
//
|
|
121
|
+
// NOTE: rival pendings in `state.pendings` are deliberately not remembered for a refresh
|
|
122
|
+
// before the next pend. It would save one doomed pend round only when the rival commits in
|
|
123
|
+
// between; the hint goes stale on a cache hit (which never re-reads), stuck records would
|
|
124
|
+
// trigger refreshes for nothing (backlog `debt-unpromotable-pending-records-need-a-sweep`),
|
|
125
|
+
// and while the rival is still pending a refresh changes nothing and the pend is refused
|
|
126
|
+
// `held` anyway. Revisit if lost pend rounds after a rival commit show up in measurements.
|
|
123
127
|
return block;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactor-source.js","sourceRoot":"","sources":["../../../src/transactor/transactor-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAEtE,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAA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uFAAuF;gBACvF,IAAI,CAAC;oBAAE,CAA+B,CAAC,WAAW,GAAG,WAAW,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;YAC3F,CAAC;YACD,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;IAED;;;;;;;;;;OAUG;IACK,KAAK,CAAC,aAAa,CAAC,QAAkB,EAAE,QAAmB;QAClE,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACrD,OAAO,SAAS,CAAC;QAClB,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACtB,GAAG,CAAC,8EAA8E,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YACrH,OAAO,WAAW,CAAC;QACpB,CAAC;IACF,CAAC;CACD"}
|
package/package.json
CHANGED
package/src/cluster/structs.ts
CHANGED
|
@@ -368,6 +368,19 @@ export interface ClusterConsensusConfig {
|
|
|
368
368
|
* `reconcilePassTimeoutMs` in the same module.
|
|
369
369
|
*/
|
|
370
370
|
cohortQueryTimeoutMs?: number;
|
|
371
|
+
/**
|
|
372
|
+
* How long a member holds the next slot of a block for a writer it has itself refused as stale
|
|
373
|
+
* `SlotHoldAfterLosses` times, in milliseconds, before the hold expires unconsumed (default
|
|
374
|
+
* 3000; see `resolveSlotHoldWindowMs` in db-p2p's `cluster/cluster-policy.ts`). `0` disables the
|
|
375
|
+
* mechanism on that member — no loss is counted, no hold granted, no pend checked against one.
|
|
376
|
+
*
|
|
377
|
+
* While a hold stands the block admits no other writer's pend, so the window is also the worst
|
|
378
|
+
* case a holder that never returns can idle the block per grant; an honest holder consumes it in
|
|
379
|
+
* its own read-to-pend time, well under the default. Size it above the slowest honest writer's
|
|
380
|
+
* refresh-plus-pend round trip (several sequential reads on the link it uses), and no larger.
|
|
381
|
+
* A value that is not a finite number at or above zero throws at node construction.
|
|
382
|
+
*/
|
|
383
|
+
slotHoldWindowMs?: number;
|
|
371
384
|
/**
|
|
372
385
|
* When FRET has no confident network-size estimate, allow an undersized cluster
|
|
373
386
|
* (peerCount < minAbsoluteClusterSize) to proceed anyway. Default false: with no
|
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
* local soft state; cross-member replication runs over cohort gossip in a later ticket.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { createLogger } from "../../logger.js";
|
|
11
12
|
import { bytesKey } from "./bytes.js";
|
|
12
13
|
import type { RegistrationRecord, RegistrationStore } from "./types.js";
|
|
13
14
|
|
|
15
|
+
const log = createLogger("cohort-topic:registration");
|
|
16
|
+
|
|
14
17
|
class InMemoryRegistrationStore implements RegistrationStore {
|
|
15
18
|
/** topicKey → (participantKey → record). Inner maps are pruned when they empty. */
|
|
16
19
|
private readonly byTopic = new Map<string, Map<string, RegistrationRecord>>();
|
|
@@ -79,3 +82,68 @@ class InMemoryRegistrationStore implements RegistrationStore {
|
|
|
79
82
|
export function createRegistrationStore(): RegistrationStore {
|
|
80
83
|
return new InMemoryRegistrationStore();
|
|
81
84
|
}
|
|
85
|
+
|
|
86
|
+
/** Called once per record that a `put` made present where the store held none for its participant. */
|
|
87
|
+
export type RecordAddedListener = (rec: RegistrationRecord) => void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A store that reports each absent→present `put`. Every way a record reaches a member — local
|
|
91
|
+
* admission, a gossip merge, a rotation-handoff pull — goes through `put`, so this is the one place
|
|
92
|
+
* a "a registration arrived here" signal can be taken without missing a path. A `put` that replaces
|
|
93
|
+
* a held record (a renewal touch, a re-attach restamp, a re-merge) reports nothing.
|
|
94
|
+
*/
|
|
95
|
+
class RecordAdditionObserver implements RegistrationStore {
|
|
96
|
+
constructor(
|
|
97
|
+
private readonly inner: RegistrationStore,
|
|
98
|
+
private readonly onAdded: RecordAddedListener,
|
|
99
|
+
) {}
|
|
100
|
+
|
|
101
|
+
put(rec: RegistrationRecord): void {
|
|
102
|
+
const added = this.inner.getByParticipant(rec.topicId, rec.participantId) === undefined;
|
|
103
|
+
this.inner.put(rec);
|
|
104
|
+
if (added) {
|
|
105
|
+
this.notify(rec);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getByParticipant(topicId: Uint8Array, participantId: Uint8Array): RegistrationRecord | undefined {
|
|
110
|
+
return this.inner.getByParticipant(topicId, participantId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
listByTopic(topicId: Uint8Array): readonly RegistrationRecord[] {
|
|
114
|
+
return this.inner.listByTopic(topicId);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
listAll(): readonly RegistrationRecord[] {
|
|
118
|
+
return this.inner.listAll();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
delete(topicId: Uint8Array, participantId: Uint8Array): void {
|
|
122
|
+
this.inner.delete(topicId, participantId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
directParticipants(topicId: Uint8Array): number {
|
|
126
|
+
return this.inner.directParticipants(topicId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
evictStale(now: number): readonly RegistrationRecord[] {
|
|
130
|
+
return this.inner.evictStale(now);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A listener fault must not abort the admission or gossip merge that called `put`. */
|
|
134
|
+
private notify(rec: RegistrationRecord): void {
|
|
135
|
+
try {
|
|
136
|
+
this.onAdded(rec);
|
|
137
|
+
} catch (err) {
|
|
138
|
+
log("record-added listener threw for topic %s participant %s: %o", bytesKey(rec.topicId), bytesKey(rec.participantId), err);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Wrap `store` so `onAdded` fires after each `put` that makes a `(topicId, participantId)` record
|
|
145
|
+
* present where none was held. A listener throw is logged, never propagated into `put`.
|
|
146
|
+
*/
|
|
147
|
+
export function observeRecordAdditions(store: RegistrationStore, onAdded: RecordAddedListener): RegistrationStore {
|
|
148
|
+
return new RecordAdditionObserver(store, onAdded);
|
|
149
|
+
}
|
|
@@ -23,6 +23,12 @@ import { b64urlToBytes } from "./codec.js";
|
|
|
23
23
|
*/
|
|
24
24
|
export const COORD_BYTES = 32;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Correlation-id byte width: the 16-byte nonce the cohort-topic substrate mints per walk probe / renew,
|
|
28
|
+
* and the matchmaking seeker registration id an arrival push is bound to.
|
|
29
|
+
*/
|
|
30
|
+
export const CORRELATION_BYTES = 16;
|
|
31
|
+
|
|
26
32
|
/** Thrown for any malformed, oversized, or structurally invalid cohort-topic frame. */
|
|
27
33
|
export class CohortWireError extends Error {
|
|
28
34
|
constructor(message: string) {
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
b64urlField,
|
|
17
17
|
b64urlFixedLen,
|
|
18
18
|
COORD_BYTES,
|
|
19
|
+
CORRELATION_BYTES,
|
|
19
20
|
failWire as fail,
|
|
20
21
|
optBool,
|
|
21
22
|
optFiniteNumber,
|
|
@@ -78,9 +79,6 @@ function treeTier(value: number, what: string): number {
|
|
|
78
79
|
return value;
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
/** Correlation-id byte width (a 16-byte nonce minted per walk probe / renew). */
|
|
82
|
-
const CORRELATION_BYTES = 16;
|
|
83
|
-
|
|
84
82
|
/**
|
|
85
83
|
* Ceiling on a decoded `rootKey` (the root key of a root-placed topic). A root key is a block's routing
|
|
86
84
|
* key — the UTF-8 of its block id, 43 bytes for a generated id — so 256 leaves room for a named block
|
package/src/collection/action.ts
CHANGED
|
@@ -26,7 +26,21 @@ export type ActionContext = {
|
|
|
26
26
|
committed: ActionRev[];
|
|
27
27
|
/** The latest known revision number */
|
|
28
28
|
rev: number;
|
|
29
|
-
/** Optional uncommitted pending action
|
|
29
|
+
/** Optional uncommitted pending action to read through. A repo overlays this action's pending
|
|
30
|
+
* transform on each block where it holds a pending record of it, and answers every other block
|
|
31
|
+
* exactly as a plain read with the same context would; the overlay answer's `state.pendings`
|
|
32
|
+
* names the action, the plain one's does not.
|
|
33
|
+
*
|
|
34
|
+
* No production code sets it. It is reserved for tentative reads in long-lived pend (backlog
|
|
35
|
+
* `feat-long-lived-pend-completes-as-members-appear`), where a read that observes a
|
|
36
|
+
* pended-but-uncommitted revision makes the reading transaction tentative too. It is
|
|
37
|
+
* deliberately not used for early abort: the only certain abort signal — a latest revision at
|
|
38
|
+
* or past the pended one under another action — is already on a plain read's `state.latest`.
|
|
39
|
+
* Whoever sets it must keep the overlay answer out of every cache as committed content: mark it
|
|
40
|
+
* `mayRetain: false` through `TransactorSource.describeServed`, and record no read dependency
|
|
41
|
+
* for it. The content is no committed revision, and the answer's `materialized` revision names
|
|
42
|
+
* the base under the overlay, not the content (see "Staged Edits Keep Their Base" in
|
|
43
|
+
* `docs/internals.md`). */
|
|
30
44
|
actionId?: ActionId;
|
|
31
45
|
};
|
|
32
46
|
|
|
@@ -20,12 +20,13 @@ import { CollectionHeaderVanishedError, SyncRetryExhaustedError, SyncRevisionSta
|
|
|
20
20
|
import type { ActionContext } from "./action.js";
|
|
21
21
|
import { actionIdAt } from "./action.js";
|
|
22
22
|
import type { ReadDependency } from "../transaction/transaction.js";
|
|
23
|
-
import { clampPriority } from "../transaction/transaction.js";
|
|
23
|
+
import { clampPriority, SlotHoldAfterLosses } from "../transaction/transaction.js";
|
|
24
24
|
import { ReadDependencyCollector } from "../transaction/read-dependency-collector.js";
|
|
25
25
|
import { randomBytes } from '@noble/hashes/utils.js';
|
|
26
26
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
27
27
|
import { Latches } from "../utility/latches.js";
|
|
28
28
|
import { jitteredBackoffMs, abortableDelay, makeAbortError } from "../utility/backoff.js";
|
|
29
|
+
import type { JitteredBackoffConfig, RandFn } from "../utility/backoff.js";
|
|
29
30
|
import { createLogger } from "../logger.js";
|
|
30
31
|
|
|
31
32
|
const log = createLogger('collection');
|
|
@@ -117,6 +118,32 @@ const DefaultMaxBackoffMs = 5000;
|
|
|
117
118
|
* spurious `SyncRevisionStalledError` ever shows up under real contention anyway, raise this. */
|
|
118
119
|
const DefaultMaxStalledAttempts = 2;
|
|
119
120
|
|
|
121
|
+
/**
|
|
122
|
+
* The sleep before the refresh that follows a write's `failures`-th consecutive loss.
|
|
123
|
+
*
|
|
124
|
+
* The jittered backoff exists to separate a herd of writers that lost the SAME race, so they do not
|
|
125
|
+
* re-collide on the next tick. A loss to a rival that had already committed (the refusal carried a
|
|
126
|
+
* confirmed `staleAt`) is not a herd, and once this write has taken `SlotHoldAfterLosses` such losses
|
|
127
|
+
* (`confirmedLosses`, counted over the whole write as a member counts its stale refusals of one
|
|
128
|
+
* action) the members that refused it hold the next slot for it — so sleeping only spends that hold.
|
|
129
|
+
* Both sides count the same refusals against the same constant, so the writer stops sleeping on the
|
|
130
|
+
* loss after which a member holds, with nothing said over the wire. A loss the latest refusal did not
|
|
131
|
+
* confirm (`latestConfirmed` false — a race against something still in flight) keeps the jitter.
|
|
132
|
+
*
|
|
133
|
+
* NOTE: against members that do not hold (an earlier release, `slotHoldWindowMs: 0`, or a member the
|
|
134
|
+
* refused pends did not reach) this retries without sleeping and so spends the same attempt budget
|
|
135
|
+
* sooner, at about twice one writer's pend rate (measured in the plan stage of
|
|
136
|
+
* `slot-hold-for-an-aged-writer`). Accepted: the backoff bought that writer nothing either, it only
|
|
137
|
+
* delayed the same give-up.
|
|
138
|
+
*/
|
|
139
|
+
function retryBackoffMs(failures: number, confirmedLosses: number, latestConfirmed: boolean,
|
|
140
|
+
config: JitteredBackoffConfig, rand?: RandFn): number {
|
|
141
|
+
if (latestConfirmed && confirmedLosses >= SlotHoldAfterLosses) {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
return jitteredBackoffMs(failures - 1, config, rand);
|
|
145
|
+
}
|
|
146
|
+
|
|
120
147
|
export type CollectionInitOptions<TAction> = {
|
|
121
148
|
modules: Record<ActionType, ActionHandler<TAction>>;
|
|
122
149
|
createHeaderBlock: (id: BlockId, store: BlockStore<IBlock>) => IBlock;
|
|
@@ -1770,6 +1797,10 @@ export class Collection<TAction> implements ICollection<TAction> {
|
|
|
1770
1797
|
// responder to have re-confirmed the number this round, not merely an older observation
|
|
1771
1798
|
// left standing in `lastStaleAt`.
|
|
1772
1799
|
let lastFailureConfirmedStaleAt = false;
|
|
1800
|
+
// Refused attempts of this write that carried their own staleAt. Never reset: a member counts
|
|
1801
|
+
// its stale refusals per action for the action's whole life, and this is the writer's view of
|
|
1802
|
+
// that count (see retryBackoffMs).
|
|
1803
|
+
let confirmedLosses = 0;
|
|
1773
1804
|
// Consecutive refreshes that moved `getNextRev()` nowhere at all while a confirmed revision
|
|
1774
1805
|
// stood at or above it.
|
|
1775
1806
|
let consecutiveStalls = 0;
|
|
@@ -1921,6 +1952,7 @@ export class Collection<TAction> implements ICollection<TAction> {
|
|
|
1921
1952
|
// producers and the transactor's aggregation already use.
|
|
1922
1953
|
lastStaleAt = highestStaleAt([lastStaleAt, attempt.staleAt]);
|
|
1923
1954
|
lastFailureConfirmedStaleAt = attempt.staleAt !== undefined;
|
|
1955
|
+
if (lastFailureConfirmedStaleAt) confirmedLosses++;
|
|
1924
1956
|
// Give up once the consecutive no-progress budget is exhausted, so a transactor that
|
|
1925
1957
|
// persistently rejects the sync can no longer hold the collection latch forever.
|
|
1926
1958
|
// NOTE: this also bounds the legitimate `pending`-wait case (retrying the same action
|
|
@@ -1956,17 +1988,23 @@ export class Collection<TAction> implements ICollection<TAction> {
|
|
|
1956
1988
|
// is byte-identical — see logAppendBlockIds — so what is at stake is the second entry,
|
|
1957
1989
|
// not two versions of one tail block.) Each round is a failure against the same
|
|
1958
1990
|
// no-progress budget as a refused attempt.
|
|
1991
|
+
// Whether the failure just handled was a loss to a rival already durably committed. Only
|
|
1992
|
+
// the attempt's own refusal can say so; a refresh refused for a cause that can clear
|
|
1993
|
+
// (below) is a race against something still in flight, and clears it.
|
|
1994
|
+
let latestConfirmed = lastFailureConfirmedStaleAt;
|
|
1959
1995
|
for (;;) {
|
|
1960
1996
|
// Back off before every retry (any stale failure — reason/missing/pending), growing
|
|
1961
1997
|
// exponentially from the base delay up to the cap, with proportional random jitter so a
|
|
1962
1998
|
// herd of clients that lost the same race does not re-collide on the next tick (see
|
|
1963
|
-
// utility/backoff.ts)
|
|
1964
|
-
//
|
|
1999
|
+
// utility/backoff.ts) — except once this write has lost to committed rivals often enough
|
|
2000
|
+
// that a member holds the next slot for it (see retryBackoffMs). The abortable sleep lets
|
|
2001
|
+
// an aborted sync reject promptly instead of finishing the sleep.
|
|
1965
2002
|
// NOTE: the `missing`/`reason` conflict paths now pay this backoff too (they previously
|
|
1966
2003
|
// retried with zero delay); that is what stops the persistent-`reason` hot spin. If a
|
|
1967
2004
|
// high-contention workload ever shows this base delay as recovery latency, lower
|
|
1968
2005
|
// baseBackoffMs for that caller rather than reintroducing the zero-delay retry.
|
|
1969
|
-
const delay =
|
|
2006
|
+
const delay = retryBackoffMs(consecutiveFailures, confirmedLosses, latestConfirmed,
|
|
2007
|
+
{ baseMs: baseBackoffMs, capMs: maxBackoffMs }, options?.rand);
|
|
1970
2008
|
await abortableDelay(delay, signal);
|
|
1971
2009
|
try {
|
|
1972
2010
|
// Fetch latest state - updateInternal() will call replayActions() if there are conflicts.
|
|
@@ -2005,6 +2043,7 @@ export class Collection<TAction> implements ICollection<TAction> {
|
|
|
2005
2043
|
// is what escapes: the log holds an entry for a write that was not saved.
|
|
2006
2044
|
consecutiveFailures++;
|
|
2007
2045
|
lastReason = err.detail;
|
|
2046
|
+
latestConfirmed = false;
|
|
2008
2047
|
if (consecutiveFailures >= maxAttempts
|
|
2009
2048
|
|| (deadlineMs !== undefined && Date.now() - startedAt >= deadlineMs)) {
|
|
2010
2049
|
throw err;
|
package/src/collection/struct.ts
CHANGED
|
@@ -19,9 +19,13 @@ export interface SyncOptions {
|
|
|
19
19
|
* of the attempt count — a progress-agnostic ceiling. Unset means no deadline. */
|
|
20
20
|
deadlineMs?: number;
|
|
21
21
|
/** Base backoff delay in ms applied before the first retry; subsequent retries grow the delay
|
|
22
|
-
* exponentially up to {@link maxBackoffMs}. Default 100.
|
|
22
|
+
* exponentially up to {@link maxBackoffMs}. Default 100. Not applied once `SlotHoldAfterLosses` of the
|
|
23
|
+
* write's refused attempts carried a confirmed committed revision (`StaleFailure.staleAt`) and the
|
|
24
|
+
* latest refusal is one of them: a member then holds the next slot for this write,
|
|
25
|
+
* and the retry follows at once rather than spending the hold asleep. */
|
|
23
26
|
baseBackoffMs?: number;
|
|
24
|
-
/** Upper bound on any single backoff sleep, in ms. Default 5000.
|
|
27
|
+
/** Upper bound on any single backoff sleep, in ms. Default 5000. Like {@link baseBackoffMs}, not
|
|
28
|
+
* applied to a retry that follows at once because a member holds the slot for this write. */
|
|
25
29
|
maxBackoffMs?: number;
|
|
26
30
|
/** Optional abort signal. Checked at the top of each loop iteration and raced against the
|
|
27
31
|
* backoff sleep, so an aborted sync rejects promptly (with an AbortError) rather than finishing
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matchmaking — arrival-push fan-out selection (db-core, pure).
|
|
3
|
+
*
|
|
4
|
+
* Decides which push-opted seekers a newly arrived provider is pushed to (`docs/matchmaking.md`
|
|
5
|
+
* §Fairness — FCFS by `attachedAt`, fan-out bounded by `capacityBudget`). Every cohort member runs the
|
|
6
|
+
* same selection over the same gossip-replicated records and then delivers only to the selected seekers
|
|
7
|
+
* whose slot primary it is, so the cohort as a whole notifies about `capacityBudget` seekers rather than
|
|
8
|
+
* that many per member.
|
|
9
|
+
*
|
|
10
|
+
* Pure: no clock, no I/O. The db-p2p cohort driver decodes the records, keeps the targets it is primary
|
|
11
|
+
* for, coalesces, signs and delivers.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { matchesFilter } from "./capability-filter.js";
|
|
15
|
+
import type { LocalProviderRegistration, LocalSeekerRegistration } from "./query-eval.js";
|
|
16
|
+
|
|
17
|
+
/** A decoded seeker registration held at this cohort, considered as a push target. */
|
|
18
|
+
export type ArrivalPushCandidate = LocalSeekerRegistration;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Seekers to notify about `provider`, longest-waiting first: of the push-opted seekers whose filter the
|
|
22
|
+
* provider matches and that attached no later than it did, the first `capacityBudget` by `attachedAt`
|
|
23
|
+
* (ties broken by `participantId`, so every member computes the same order). Generic so the caller gets
|
|
24
|
+
* back its own richer candidate objects.
|
|
25
|
+
*
|
|
26
|
+
* The `attachedAt` rule exists for a member that receives the whole record set at once (catching up by
|
|
27
|
+
* gossip, or pulling records in a rotation handoff): without it, that member would push every existing
|
|
28
|
+
* provider to every seeker. A provider that attached before a seeker was answerable by that seeker's own
|
|
29
|
+
* first query, and its safety poll still finds it.
|
|
30
|
+
*
|
|
31
|
+
* NOTE: accepted tradeoff — the ranking reads only replicated state, so a seeker already satisfied,
|
|
32
|
+
* finished, or answering `unknown_seeker` to its own primary keeps holding a fan-out slot until its
|
|
33
|
+
* record leaves the cohort (withdraw on finish, or its `seeker_ttl` expiry), under-filling that arrival's fan-out;
|
|
34
|
+
* members whose gossip views differ can also over- or under-fill by a few. Excluding them would mean
|
|
35
|
+
* gossiping per-seeker push state; the seeker's safety poll covers what is missed. Revisit if push
|
|
36
|
+
* under-fill shows up as seekers routinely falling back to the safety poll on a busy topic.
|
|
37
|
+
*/
|
|
38
|
+
export function selectArrivalPushTargets<S extends ArrivalPushCandidate>(
|
|
39
|
+
provider: LocalProviderRegistration,
|
|
40
|
+
seekers: readonly S[],
|
|
41
|
+
): S[] {
|
|
42
|
+
const budget = provider.payload.capacityBudget;
|
|
43
|
+
if (budget === 0) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return seekers
|
|
47
|
+
.filter((s) => isPushTarget(provider, s))
|
|
48
|
+
.sort(byLongestWaiting)
|
|
49
|
+
.slice(0, budget);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** True iff `seeker` holds a push binding, matches `provider`, and was waiting when it arrived. */
|
|
53
|
+
function isPushTarget(provider: LocalProviderRegistration, seeker: ArrivalPushCandidate): boolean {
|
|
54
|
+
return seeker.payload.pushOnArrival === true
|
|
55
|
+
&& seeker.payload.correlationId !== undefined
|
|
56
|
+
&& matchesFilter(provider.payload, seeker.payload.filter)
|
|
57
|
+
&& provider.attachedAt >= seeker.attachedAt;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Ascending `attachedAt`, then code-unit order of `participantId` (locale-independent, so members agree). */
|
|
61
|
+
function byLongestWaiting(a: ArrivalPushCandidate, b: ArrivalPushCandidate): number {
|
|
62
|
+
if (a.attachedAt !== b.attachedAt) {
|
|
63
|
+
return a.attachedAt - b.attachedAt;
|
|
64
|
+
}
|
|
65
|
+
return a.participantId < b.participantId ? -1 : a.participantId > b.participantId ? 1 : 0;
|
|
66
|
+
}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* The TTL/limit constants are wire-stable and do **not** depend on simulator findings; the hang-out
|
|
11
11
|
* rows DO (folded via `fold-simulator-findings-into-design-docs`) — they carry the simulator-validated
|
|
12
12
|
* defaults (`contention_factor_cap = 4.0`, `mean_want_count = 3`, …; see `docs/matchmaking.md`
|
|
13
|
-
* §Configuration "Defaults validated by simulator").
|
|
14
|
-
*
|
|
13
|
+
* §Configuration "Defaults validated by simulator"). Of the arrival-push rows, `push_safety_poll_ms` is
|
|
14
|
+
* seeker-side and lives on {@link HangOutConfig}; `push_coalesce_ms` is the one cohort-side knob and
|
|
15
|
+
* lives on {@link ArrivalPushConfig}.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import type { NodeProfile } from "../cohort-topic/tiers.js";
|
|
@@ -61,12 +62,26 @@ export interface HangOutConfig {
|
|
|
61
62
|
readonly contentionFactorCap: number;
|
|
62
63
|
/** Hang-out poll cadence on the non-push path. */
|
|
63
64
|
readonly requeryIntervalMs: number;
|
|
65
|
+
/** Sparse safety-poll cadence beneath the pushes, for a seeker that set `pushOnArrival`. */
|
|
66
|
+
readonly pushSafetyPollMs: number;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
/** The default hang-out decision config (simulator-validated). */
|
|
67
70
|
export const DEFAULT_HANG_OUT_CONFIG: HangOutConfig = {
|
|
68
71
|
contentionFactorCap: CONTENTION_FACTOR_CAP,
|
|
69
72
|
requeryIntervalMs: REQUERY_INTERVAL_MS,
|
|
73
|
+
pushSafetyPollMs: PUSH_SAFETY_POLL_MS,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Cohort-side arrival-push tuning (`docs/matchmaking.md` §Coalescing). */
|
|
77
|
+
export interface ArrivalPushConfig {
|
|
78
|
+
/** Window the pushing member batches fresh matchable arrivals per seeker before flushing one push. */
|
|
79
|
+
readonly coalesceMs: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The default arrival-push config. */
|
|
83
|
+
export const DEFAULT_ARRIVAL_PUSH_CONFIG: ArrivalPushConfig = {
|
|
84
|
+
coalesceMs: PUSH_COALESCE_MS,
|
|
70
85
|
};
|
|
71
86
|
|
|
72
87
|
/** The full matchmaking config, with the documented defaults. */
|
package/src/matchmaking/index.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* See `docs/matchmaking.md`. The db-core layer owns the transport-agnostic pieces: wire codecs +
|
|
5
5
|
* seeker-side entry re-validation, the stable topic-anchor derivation, configuration, both
|
|
6
6
|
* registration roles' decision/state (provider attach/renew/self-throttle; seeker short-TTL
|
|
7
|
-
* registration), the cohort-side capability filter + pure query evaluation,
|
|
8
|
-
* hang-out-vs-continue decision engine. The db-p2p layer wires these to the cohort-topic substrate
|
|
7
|
+
* registration), the cohort-side capability filter + pure query evaluation, the arrival-push fan-out
|
|
8
|
+
* selection, and the seeker hang-out-vs-continue decision engine. The db-p2p layer wires these to the cohort-topic substrate
|
|
9
9
|
* (managers, the cohort query handler, the seeker walk client).
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -16,6 +16,7 @@ export * from "./provider.js";
|
|
|
16
16
|
export * from "./seeker.js";
|
|
17
17
|
export * from "./capability-filter.js";
|
|
18
18
|
export * from "./query-eval.js";
|
|
19
|
+
export * from "./arrival-push.js";
|
|
19
20
|
export * from "./seeker-walk.js";
|
|
20
21
|
export * from "./multi-cohort-seeker.js";
|
|
21
22
|
export * from "./voting-quorum.js";
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { randomBytes } from "@noble/hashes/utils.js";
|
|
18
|
+
import { bytesToB64url } from "../cohort-topic/wire/codec.js";
|
|
19
|
+
import { CORRELATION_BYTES } from "../cohort-topic/wire/primitives.js";
|
|
18
20
|
import { seekerSigningPayload, type CapabilityFilter, type SeekerAppPayloadV1, encodeSeekerAppPayload } from "./wire.js";
|
|
19
21
|
|
|
20
22
|
/** Construction inputs for a {@link MatchmakingSeeker}. */
|
|
@@ -27,11 +29,14 @@ export interface MatchmakingSeekerOptions {
|
|
|
27
29
|
readonly contactHint: string;
|
|
28
30
|
/** Optional capability filter (evaluated cohort-side in the next ticket; carried here). */
|
|
29
31
|
readonly filter?: CapabilityFilter;
|
|
30
|
-
/** Opt into arrival pushes; default false (poll path).
|
|
32
|
+
/** Opt into arrival pushes; default false (poll path). */
|
|
31
33
|
readonly pushOnArrival?: boolean;
|
|
32
34
|
/** Sign the canonical registration image; resolves the base64url signature. */
|
|
33
35
|
readonly sign: (payload: Uint8Array) => Promise<string>;
|
|
34
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* 16-byte registration correlation id (not signature-bound); default fresh CSPRNG bytes. Sent in the
|
|
38
|
+
* payload when `pushOnArrival` is set, as the id arrival pushes are bound to.
|
|
39
|
+
*/
|
|
35
40
|
readonly correlationId?: Uint8Array;
|
|
36
41
|
/** CSPRNG source (injectable for deterministic tests). Default `@noble/hashes` `randomBytes`. */
|
|
37
42
|
readonly randomBytes?: (n: number) => Uint8Array;
|
|
@@ -58,7 +63,7 @@ export class MatchmakingSeeker {
|
|
|
58
63
|
this.pushOnArrival = options.pushOnArrival;
|
|
59
64
|
this.sign = options.sign;
|
|
60
65
|
const rand = options.randomBytes ?? randomBytes;
|
|
61
|
-
this.correlationId = options.correlationId ?? rand(
|
|
66
|
+
this.correlationId = options.correlationId ?? rand(CORRELATION_BYTES);
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/** Build the signed {@link SeekerAppPayloadV1} for this seeker's registration. */
|
|
@@ -76,6 +81,9 @@ export class MatchmakingSeeker {
|
|
|
76
81
|
if (this.pushOnArrival !== undefined) {
|
|
77
82
|
payload.pushOnArrival = this.pushOnArrival;
|
|
78
83
|
}
|
|
84
|
+
if (this.pushOnArrival === true) {
|
|
85
|
+
payload.correlationId = bytesToB64url(this.correlationId);
|
|
86
|
+
}
|
|
79
87
|
return payload;
|
|
80
88
|
}
|
|
81
89
|
|