@optimystic/db-core 1.9.0 → 1.10.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/cohort-topic/addressing.d.ts +46 -6
- package/dist/src/cohort-topic/addressing.d.ts.map +1 -1
- package/dist/src/cohort-topic/addressing.js +58 -18
- package/dist/src/cohort-topic/addressing.js.map +1 -1
- package/dist/src/cohort-topic/member-engine.d.ts +21 -1
- package/dist/src/cohort-topic/member-engine.d.ts.map +1 -1
- package/dist/src/cohort-topic/member-engine.js +39 -9
- package/dist/src/cohort-topic/member-engine.js.map +1 -1
- package/dist/src/cohort-topic/membership/publisher.js +1 -1
- package/dist/src/cohort-topic/membership/publisher.js.map +1 -1
- package/dist/src/cohort-topic/membership/source.d.ts +4 -0
- package/dist/src/cohort-topic/membership/source.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/source.js +4 -0
- package/dist/src/cohort-topic/membership/source.js.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.d.ts +51 -9
- package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -1
- package/dist/src/cohort-topic/membership/verifier.js +138 -46
- package/dist/src/cohort-topic/membership/verifier.js.map +1 -1
- package/dist/src/cohort-topic/ports.d.ts +85 -14
- package/dist/src/cohort-topic/ports.d.ts.map +1 -1
- package/dist/src/cohort-topic/ports.js +1 -1
- package/dist/src/cohort-topic/ports.js.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.d.ts +26 -5
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
- package/dist/src/cohort-topic/registration/renewal.js +71 -21
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
- package/dist/src/cohort-topic/service.d.ts +34 -2
- package/dist/src/cohort-topic/service.d.ts.map +1 -1
- package/dist/src/cohort-topic/service.js +86 -28
- package/dist/src/cohort-topic/service.js.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.d.ts +5 -1
- package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/sig/payloads.js +6 -1
- package/dist/src/cohort-topic/sig/payloads.js.map +1 -1
- package/dist/src/cohort-topic/sig/threshold.d.ts +29 -4
- package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -1
- package/dist/src/cohort-topic/sig/threshold.js +39 -7
- package/dist/src/cohort-topic/sig/threshold.js.map +1 -1
- package/dist/src/cohort-topic/walk.d.ts +19 -4
- package/dist/src/cohort-topic/walk.d.ts.map +1 -1
- package/dist/src/cohort-topic/walk.js +29 -6
- package/dist/src/cohort-topic/walk.js.map +1 -1
- package/dist/src/cohort-topic/willingness.d.ts +17 -1
- package/dist/src/cohort-topic/willingness.d.ts.map +1 -1
- package/dist/src/cohort-topic/willingness.js +18 -3
- package/dist/src/cohort-topic/willingness.js.map +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts +1 -1
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/index.js +1 -1
- package/dist/src/cohort-topic/wire/index.js.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.d.ts +14 -0
- package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/payloads.js +20 -0
- package/dist/src/cohort-topic/wire/payloads.js.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.d.ts +8 -0
- package/dist/src/cohort-topic/wire/primitives.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/primitives.js +24 -4
- package/dist/src/cohort-topic/wire/primitives.js.map +1 -1
- package/dist/src/cohort-topic/wire/types.d.ts +37 -0
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.d.ts +9 -1
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
- package/dist/src/cohort-topic/wire/validate.js +23 -4
- package/dist/src/cohort-topic/wire/validate.js.map +1 -1
- package/dist/src/reactivity/config.d.ts +9 -10
- package/dist/src/reactivity/config.d.ts.map +1 -1
- package/dist/src/reactivity/config.js +9 -9
- package/dist/src/reactivity/config.js.map +1 -1
- package/dist/src/reactivity/index.d.ts +4 -3
- package/dist/src/reactivity/index.d.ts.map +1 -1
- package/dist/src/reactivity/index.js +4 -3
- package/dist/src/reactivity/index.js.map +1 -1
- package/dist/src/reactivity/rotation.d.ts +73 -57
- package/dist/src/reactivity/rotation.d.ts.map +1 -1
- package/dist/src/reactivity/rotation.js +54 -54
- package/dist/src/reactivity/rotation.js.map +1 -1
- package/dist/src/reactivity/subscription.d.ts +12 -9
- package/dist/src/reactivity/subscription.d.ts.map +1 -1
- package/dist/src/reactivity/subscription.js +9 -6
- package/dist/src/reactivity/subscription.js.map +1 -1
- package/dist/src/reactivity/topic-anchor.d.ts +36 -31
- package/dist/src/reactivity/topic-anchor.d.ts.map +1 -1
- package/dist/src/reactivity/topic-anchor.js +41 -39
- package/dist/src/reactivity/topic-anchor.js.map +1 -1
- package/dist/src/reactivity/verify.d.ts +26 -9
- package/dist/src/reactivity/verify.d.ts.map +1 -1
- package/dist/src/reactivity/verify.js +26 -11
- package/dist/src/reactivity/verify.js.map +1 -1
- package/dist/src/reactivity/wire.d.ts +1 -1
- package/dist/src/reactivity/wire.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.d.ts +1 -1
- package/package.json +1 -1
- package/src/cohort-topic/addressing.ts +83 -23
- package/src/cohort-topic/member-engine.ts +77 -8
- package/src/cohort-topic/membership/publisher.ts +1 -1
- package/src/cohort-topic/membership/source.ts +4 -0
- package/src/cohort-topic/membership/verifier.ts +169 -51
- package/src/cohort-topic/ports.ts +87 -15
- package/src/cohort-topic/registration/renewal.ts +87 -24
- package/src/cohort-topic/service.ts +157 -35
- package/src/cohort-topic/sig/payloads.ts +7 -2
- package/src/cohort-topic/sig/threshold.ts +41 -7
- package/src/cohort-topic/walk.ts +46 -9
- package/src/cohort-topic/willingness.ts +34 -3
- package/src/cohort-topic/wire/index.ts +1 -0
- package/src/cohort-topic/wire/payloads.ts +21 -0
- package/src/cohort-topic/wire/primitives.ts +26 -4
- package/src/cohort-topic/wire/types.ts +37 -0
- package/src/cohort-topic/wire/validate.ts +26 -3
- package/src/reactivity/config.ts +10 -10
- package/src/reactivity/index.ts +4 -3
- package/src/reactivity/rotation.ts +86 -78
- package/src/reactivity/subscription.ts +12 -9
- package/src/reactivity/topic-anchor.ts +42 -45
- package/src/reactivity/verify.ts +36 -17
- package/src/reactivity/wire.ts +1 -1
- package/src/transactor/change-notifier.ts +1 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactivity — tail rotation lifecycle (`docs/reactivity.md` §
|
|
2
|
+
* Reactivity — tail rotation lifecycle (`docs/reactivity.md` §Anchor, §Tail rotation).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* block fills (`block_fill_size`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* A collection's topic is stable (`reactivityCollectionTopicId`, `topic-anchor.ts`); what rotates is its
|
|
5
|
+
* **root**. When the tail block fills (`block_fill_size` entries, the log's `EntriesPerBlock`) a new tail
|
|
6
|
+
* block is born and the root — the tail's storage group at `H(tailId)` — moves to the new tail's group. The
|
|
7
|
+
* tiers below the root sit at `coord_d(P, topicId)` and never move, so a rotation is "same topic, the root
|
|
8
|
+
* moved": a registration at the root re-registers under the new root key; one below the root keeps its place
|
|
9
|
+
* and only updates the root key a later re-walk would use (`CohortTopicService.moveRoot`). This module owns
|
|
10
|
+
* the subscriber- and root-side lifecycle around that move:
|
|
9
11
|
*
|
|
10
12
|
* - **Pre-announce** — the block-filling commit's notification carries {@link RotationHintV1}; built here
|
|
11
13
|
* by {@link buildRotationHint} and detected subscriber-side by {@link detectRotation}.
|
|
12
14
|
* - **Block-fill tracking** — {@link BlockFillTracker} counts transactions in the current tail block and
|
|
13
15
|
* fires anticipatory **warm-up** at `block_fill_size − warm_threshold` and the **filling** signal at
|
|
14
16
|
* `block_fill_size` (the commit that carries the hint).
|
|
15
|
-
* - **Drain** — {@link TailDrainGate} keeps the outgoing
|
|
16
|
-
* bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1}
|
|
17
|
+
* - **Drain** — {@link TailDrainGate} keeps the outgoing root serving renewals/replays for `T_drain` while
|
|
18
|
+
* bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1} naming the new tail.
|
|
17
19
|
* - **Jittered re-registration** — {@link planReRegistration} / {@link planReRegistrationWave} schedule a
|
|
18
|
-
* subscriber's
|
|
20
|
+
* subscriber's follow of the new tail over `T_rejoin_jitter` (the cohort-topic {@link RejoinJitter}),
|
|
19
21
|
* carrying its existing `lastRevision` (revisions are continuous across rotations).
|
|
20
|
-
* - **Buffer-to-checkpoint handoff** — {@link buildRotationHandoffCheckpoint} folds the outgoing
|
|
22
|
+
* - **Buffer-to-checkpoint handoff** — {@link buildRotationHandoffCheckpoint} folds the outgoing root's
|
|
21
23
|
* replay buffer into a final {@link CheckpointSummary} covering `[lastCheckpoint.toRevision + 1,
|
|
22
24
|
* rotationRevision]`, the **only** state migrated across a rotation; {@link applyRotationHandoff} lands it
|
|
23
|
-
* at the new
|
|
25
|
+
* at the new root so a `ResumeV1` spanning the rotation is recoverable.
|
|
24
26
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* state migrates; the new tree rebuilds via re-registration). It needs no code here.
|
|
27
|
+
* Tiers below the root do not drain on a rotation: only the old root stops receiving commits and releases its
|
|
28
|
+
* state after `T_drain`. It needs no code here.
|
|
28
29
|
*
|
|
29
30
|
* Coordination with [reactivity-backfill-resume-checkpoints]: that ticket owns the `ResumeReplyV1.TailRotated`
|
|
30
|
-
* variant and the `latestKnownTailId`-staleness classification; this
|
|
31
|
-
* and the rotation *condition*. The new
|
|
31
|
+
* variant and the `latestKnownTailId`-staleness classification; this module produces the handoff checkpoint
|
|
32
|
+
* and the rotation *condition*. The new root's {@link PushState.inheritedCheckpoint} (set by
|
|
32
33
|
* {@link applyRotationHandoff}) is the seam the resume classifier consults to answer a checkpoint-window
|
|
33
|
-
* resume whose span crosses the rotation: `classifyResume`/`serveResume`
|
|
34
|
+
* resume whose span crosses the rotation: `classifyResume`/`serveResume` read it (after the rolling
|
|
34
35
|
* `checkpoint` misses) and serve the inherited summary, so a cross-rotation resume no longer falls to
|
|
35
36
|
* `out_of_window` (`docs/reactivity.md` §Resume, §Tail rotation step 5). The drain-window redirect a new
|
|
36
37
|
* subscription receives, {@link RotationRedirectV1}, is serialized by {@link validateRotationRedirectV1} and
|
|
37
38
|
* rides the recover reply envelope as `kind: "rotated"` ({@link import("./recover.js").RecoverReplyV1}).
|
|
38
39
|
*/
|
|
39
|
-
import type { IRingHash } from "../cohort-topic/ports.js";
|
|
40
40
|
import type { RejoinJitter } from "../cohort-topic/antiflood/jitter.js";
|
|
41
41
|
import { type CheckpointSummary } from "./checkpoint.js";
|
|
42
42
|
import type { PushState } from "./push-state.js";
|
|
@@ -50,24 +50,42 @@ import type { NotificationV1, RotationHintV1 } from "./wire.js";
|
|
|
50
50
|
export declare function buildRotationHint(newTailId: string, fillingRevision: number): RotationHintV1;
|
|
51
51
|
/** The subscriber-side rotation verdict for one delivered notification. */
|
|
52
52
|
export interface RotationDetection {
|
|
53
|
-
/** True iff the subscriber's
|
|
53
|
+
/** True iff the subscriber's root has moved (delivered tail differs, at a newer revision) or a rotation is pre-announced. */
|
|
54
54
|
readonly rotated: boolean;
|
|
55
55
|
/** The tail id to re-register under, base64url — present iff `rotated`. */
|
|
56
56
|
readonly newTailId?: string;
|
|
57
57
|
/**
|
|
58
|
-
* True iff this is a **pre-announce**: the delivered `tailId` still matches
|
|
59
|
-
* notification's `rotationHint.newTailId` names a different successor. (False when the delivered
|
|
60
|
-
* already differs — the
|
|
58
|
+
* True iff this is a **pre-announce**: the delivered `tailId` still matches the tail the subscriber follows,
|
|
59
|
+
* but the notification's `rotationHint.newTailId` names a different successor. (False when the delivered
|
|
60
|
+
* tail already differs — the root has *already* moved.)
|
|
61
61
|
*/
|
|
62
62
|
readonly preAnnounced: boolean;
|
|
63
63
|
}
|
|
64
|
+
/** What a subscriber knows of the collection's log when a notification arrives, for {@link detectRotation}. */
|
|
65
|
+
export interface FollowedTail {
|
|
66
|
+
/** The latest tail the subscriber has followed, base64url. */
|
|
67
|
+
readonly tailId: string;
|
|
68
|
+
/**
|
|
69
|
+
* The newest revision the subscriber has seen: delivered or verified from a notification, replayed by a
|
|
70
|
+
* backfill or resume, or read from the log by its host. Revisions are allocated in order and the tail only
|
|
71
|
+
* moves forward, so no revision at or below it was announced at a tail newer than the newest tail the
|
|
72
|
+
* subscriber has seen a notification for.
|
|
73
|
+
*/
|
|
74
|
+
readonly newestRevision: number;
|
|
75
|
+
}
|
|
64
76
|
/**
|
|
65
|
-
* Detect tail rotation for a subscriber
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
77
|
+
* Detect tail rotation for a subscriber following `followed.tailId` from a delivered notification. Rotation
|
|
78
|
+
* is signaled when the delivered `tailId` **or** the `rotationHint.newTailId` differs from it
|
|
79
|
+
* (`docs/reactivity.md` §Tail rotation). An already-rotated delivery (different `tailId`) takes precedence
|
|
80
|
+
* over a pre-announce.
|
|
81
|
+
*
|
|
82
|
+
* A differing `tailId` at a revision at or below `followed.newestRevision` is **not** a rotation: the
|
|
83
|
+
* notification was announced at a tail the subscriber has already moved past. The old and the new root are
|
|
84
|
+
* different machines delivering independently, so the last notification announced at the old tail can arrive
|
|
85
|
+
* after the subscriber followed the new one; without the revision check it would read as a rotation back to
|
|
86
|
+
* the old tail and cost a registration at a root that announces nothing further.
|
|
69
87
|
*/
|
|
70
|
-
export declare function detectRotation(
|
|
88
|
+
export declare function detectRotation(followed: FollowedTail, n: Pick<NotificationV1, "tailId" | "rotationHint" | "revision">): RotationDetection;
|
|
71
89
|
/** The fill signal for one committed transaction in the current tail block. */
|
|
72
90
|
export type BlockFillSignal =
|
|
73
91
|
/** Below the warm-up threshold — nothing to do. */
|
|
@@ -95,7 +113,7 @@ export type BlockFillSignal =
|
|
|
95
113
|
};
|
|
96
114
|
/** Construction inputs for a {@link BlockFillTracker}. */
|
|
97
115
|
export interface BlockFillTrackerInit {
|
|
98
|
-
/**
|
|
116
|
+
/** Entries per log block before the tail rotates (default {@link BLOCK_FILL_SIZE_DEFAULT}, the log's `EntriesPerBlock`). */
|
|
99
117
|
readonly blockFillSize?: number;
|
|
100
118
|
/** Transactions remaining in the tail when anticipatory warm-up fires (default {@link WARM_THRESHOLD_DEFAULT}). */
|
|
101
119
|
readonly warmThreshold?: number;
|
|
@@ -132,16 +150,17 @@ export type DrainOp =
|
|
|
132
150
|
/** A replay/backfill/resume request — served through the drain. */
|
|
133
151
|
| "replay";
|
|
134
152
|
/**
|
|
135
|
-
* A `Promoted`-shaped redirect to the
|
|
136
|
-
* cohort-topic tier-based `Promoted`, this redirects to
|
|
137
|
-
* `
|
|
153
|
+
* A `Promoted`-shaped redirect to the moved root (`docs/reactivity.md` §Tail rotation step 2). Unlike the
|
|
154
|
+
* cohort-topic tier-based `Promoted`, this redirects to the same topic's **new root** — the new tail's storage
|
|
155
|
+
* group at `H(newTailId)` — so a receiver acts on `newTailId`. `newTopicId` stays on the wire and carries the
|
|
156
|
+
* collection's unchanged topic (the field predates the stable topic; it is not a redirect target).
|
|
138
157
|
*/
|
|
139
158
|
export interface RotationRedirectV1 {
|
|
140
159
|
readonly v: 1;
|
|
141
160
|
readonly result: "rotated";
|
|
142
|
-
/** New tail block id the
|
|
161
|
+
/** New tail block id the root moved to, base64url — the new root key. */
|
|
143
162
|
readonly newTailId: string;
|
|
144
|
-
/**
|
|
163
|
+
/** The collection's topic id, base64url — unchanged by a rotation. */
|
|
145
164
|
readonly newTopicId: string;
|
|
146
165
|
/** Revision at which the rotation took effect. */
|
|
147
166
|
readonly effectiveAtRevision: number;
|
|
@@ -173,18 +192,18 @@ export type DrainDecision =
|
|
|
173
192
|
export interface TailDrainGateInit {
|
|
174
193
|
/** Unix ms the rotation took effect (drain starts here). */
|
|
175
194
|
readonly rotatedAt: number;
|
|
176
|
-
/** New tail block id the
|
|
195
|
+
/** New tail block id the root moved to, base64url. */
|
|
177
196
|
readonly newTailId: string;
|
|
197
|
+
/** The collection's topic id, base64url — carried unchanged on the redirect. */
|
|
198
|
+
readonly topicId: string;
|
|
178
199
|
/** Revision at which the rotation took effect. */
|
|
179
200
|
readonly effectiveAtRevision: number;
|
|
180
201
|
/** Drain duration `T_drain` (ms, default {@link T_DRAIN_MS}). */
|
|
181
202
|
readonly tDrainMs?: number;
|
|
182
|
-
/** Ring hash for the `newTopicId` derivation (must match cohort-topic routing). Default db-core SHA-256. */
|
|
183
|
-
readonly hash?: IRingHash;
|
|
184
203
|
}
|
|
185
204
|
/**
|
|
186
|
-
* The outgoing
|
|
187
|
-
* serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new
|
|
205
|
+
* The outgoing root's drain state machine. For `T_drain` after a rotation it accepts **renewals** and
|
|
206
|
+
* serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new root;
|
|
188
207
|
* after `T_drain` it reports `drained` for everything (the subscriber re-registers from `d_max`).
|
|
189
208
|
*/
|
|
190
209
|
export declare class TailDrainGate {
|
|
@@ -200,33 +219,30 @@ export declare class TailDrainGate {
|
|
|
200
219
|
get rotationRedirect(): RotationRedirectV1;
|
|
201
220
|
/**
|
|
202
221
|
* Classify an inbound request. Within the drain window: `new_subscribe` → redirect, `renew`/`replay` →
|
|
203
|
-
* serve. After the window: `drained` (the old
|
|
222
|
+
* serve. After the window: `drained` (the old root has released its forwarder state).
|
|
204
223
|
*/
|
|
205
224
|
classify(op: DrainOp, now: number): DrainDecision;
|
|
206
225
|
}
|
|
207
|
-
/** A subscriber's planned
|
|
226
|
+
/** A subscriber's planned follow of the moved root. */
|
|
208
227
|
export interface ReRegistrationPlan {
|
|
209
|
-
/** New tail block id (raw bytes) to
|
|
228
|
+
/** New tail block id (raw bytes) — the new root key to follow. */
|
|
210
229
|
readonly newTailId: Uint8Array;
|
|
211
|
-
/** `H(newTailId ‖ "reactivity")` (raw bytes) — the new tree's topic id to register at. */
|
|
212
|
-
readonly newTopicId: Uint8Array;
|
|
213
230
|
/** The subscriber's existing `lastRevision`, carried so revisions stay continuous across the rotation. */
|
|
214
231
|
readonly lastRevision: number;
|
|
215
|
-
/** Unix ms at which to fire the
|
|
232
|
+
/** Unix ms at which to fire the follow (jittered over `T_rejoin_jitter`). */
|
|
216
233
|
readonly fireAt: number;
|
|
217
234
|
}
|
|
218
235
|
/** Inputs shared by the single and wave re-registration planners. */
|
|
219
236
|
interface ReRegistrationTarget {
|
|
220
237
|
/** The rotation hint (or any object carrying the successor `newTailId`), base64url. */
|
|
221
238
|
readonly hint: Pick<RotationHintV1, "newTailId">;
|
|
222
|
-
/** Ring hash for the `newTopicId` derivation. Default db-core SHA-256. */
|
|
223
|
-
readonly hash?: IRingHash;
|
|
224
239
|
}
|
|
225
240
|
/**
|
|
226
|
-
* Plan **one** subscriber's
|
|
227
|
-
* `
|
|
228
|
-
*
|
|
229
|
-
*
|
|
241
|
+
* Plan **one** subscriber's follow of the moved root: carry the hint's `newTailId` and the subscriber's
|
|
242
|
+
* `lastRevision`, and draw a jittered `fireAt` over `T_rejoin_jitter` via the cohort-topic
|
|
243
|
+
* {@link RejoinJitter} (`scheduleRejoin` — a uniform offset, decorrelating this subscriber's re-join from
|
|
244
|
+
* its peers). Only a registration at the root sends anything when the plan fires; one below the root
|
|
245
|
+
* updates its root key locally.
|
|
230
246
|
*/
|
|
231
247
|
export declare function planReRegistration(opts: ReRegistrationTarget & {
|
|
232
248
|
lastRevision: number;
|
|
@@ -234,9 +250,9 @@ export declare function planReRegistration(opts: ReRegistrationTarget & {
|
|
|
234
250
|
jitter: RejoinJitter;
|
|
235
251
|
}): ReRegistrationPlan;
|
|
236
252
|
/**
|
|
237
|
-
* Plan a **whole wave** of subscribers'
|
|
253
|
+
* Plan a **whole wave** of subscribers' follows of the moved root. Uses the
|
|
238
254
|
* {@link RejoinJitter.scheduleWave} hard-bound staggering so any `T_rejoin_jitter`-long window holds at
|
|
239
|
-
* most the injected jitter's `capPromote` arrivals — the new
|
|
255
|
+
* most the injected jitter's `capPromote` arrivals — the new root never sees more than
|
|
240
256
|
* `capPromote / T_rejoin_jitter` re-registrations per second.
|
|
241
257
|
*
|
|
242
258
|
* **Caller contract:** rotation is governed by the *fast-promote* bound, so the host MUST build this `jitter`
|
|
@@ -252,7 +268,7 @@ export declare function planReRegistrationWave(opts: ReRegistrationTarget & {
|
|
|
252
268
|
now: number;
|
|
253
269
|
jitter: RejoinJitter;
|
|
254
270
|
}): ReRegistrationPlan[];
|
|
255
|
-
/** The state migrated from the outgoing
|
|
271
|
+
/** The state migrated from the outgoing root to the new root on rotation. */
|
|
256
272
|
export interface RotationHandoff {
|
|
257
273
|
/** The final checkpoint covering `[lastCheckpoint.toRevision + 1, rotationRevision]`. */
|
|
258
274
|
readonly checkpoint: CheckpointSummary;
|
|
@@ -260,7 +276,7 @@ export interface RotationHandoff {
|
|
|
260
276
|
readonly rotationRevision: number;
|
|
261
277
|
}
|
|
262
278
|
/**
|
|
263
|
-
* Fold the outgoing
|
|
279
|
+
* Fold the outgoing root's replay buffer into the final {@link CheckpointSummary} handed to the new root
|
|
264
280
|
* (`docs/reactivity.md` §Tail rotation step 5 — the **only** state migration across a rotation). The
|
|
265
281
|
* handoff covers `[lastCheckpoint.toRevision + 1, rotationRevision]`: the revisions still live in the
|
|
266
282
|
* replay ring (above the rolling checkpoint's high edge) up to the rotation revision. Returns `undefined`
|
|
@@ -271,10 +287,10 @@ export declare function buildRotationHandoffCheckpoint(state: PushState, opts?:
|
|
|
271
287
|
rotationRevision?: number;
|
|
272
288
|
}): RotationHandoff | undefined;
|
|
273
289
|
/**
|
|
274
|
-
* Land a {@link RotationHandoff} at the new
|
|
275
|
-
* `ResumeV1` whose span crosses the rotation is recoverable from the new
|
|
290
|
+
* Land a {@link RotationHandoff} at the new root's {@link PushState}: record the inherited checkpoint so a
|
|
291
|
+
* `ResumeV1` whose span crosses the rotation is recoverable from the new root (the new root "holds the old
|
|
276
292
|
* checkpoint", `docs/reactivity.md` §Tail rotation step 5). The handoff is a one-time migration — it does
|
|
277
|
-
* not feed the new
|
|
293
|
+
* not feed the new root's rolling checkpoint (that rolls from the new root's own replay-ring eviction).
|
|
278
294
|
*/
|
|
279
295
|
export declare function applyRotationHandoff(newTailState: PushState, handoff: RotationHandoff): void;
|
|
280
296
|
/** True iff `summary` covers `revision` (its inclusive `[fromRevision, toRevision]` span). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../../src/reactivity/rotation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../../src/reactivity/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAA0B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKhE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,cAAc,CAE5F;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IACjC,6HAA6H;IAC7H,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAC/B;AAED,+GAA+G;AAC/G,MAAM,WAAW,YAAY;IAC5B,8DA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AID,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,eAAe,GAAG,SAAS,CAiBtI;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAE5F;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEtF"}
|
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactivity — tail rotation lifecycle (`docs/reactivity.md` §
|
|
2
|
+
* Reactivity — tail rotation lifecycle (`docs/reactivity.md` §Anchor, §Tail rotation).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* block fills (`block_fill_size`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* A collection's topic is stable (`reactivityCollectionTopicId`, `topic-anchor.ts`); what rotates is its
|
|
5
|
+
* **root**. When the tail block fills (`block_fill_size` entries, the log's `EntriesPerBlock`) a new tail
|
|
6
|
+
* block is born and the root — the tail's storage group at `H(tailId)` — moves to the new tail's group. The
|
|
7
|
+
* tiers below the root sit at `coord_d(P, topicId)` and never move, so a rotation is "same topic, the root
|
|
8
|
+
* moved": a registration at the root re-registers under the new root key; one below the root keeps its place
|
|
9
|
+
* and only updates the root key a later re-walk would use (`CohortTopicService.moveRoot`). This module owns
|
|
10
|
+
* the subscriber- and root-side lifecycle around that move:
|
|
9
11
|
*
|
|
10
12
|
* - **Pre-announce** — the block-filling commit's notification carries {@link RotationHintV1}; built here
|
|
11
13
|
* by {@link buildRotationHint} and detected subscriber-side by {@link detectRotation}.
|
|
12
14
|
* - **Block-fill tracking** — {@link BlockFillTracker} counts transactions in the current tail block and
|
|
13
15
|
* fires anticipatory **warm-up** at `block_fill_size − warm_threshold` and the **filling** signal at
|
|
14
16
|
* `block_fill_size` (the commit that carries the hint).
|
|
15
|
-
* - **Drain** — {@link TailDrainGate} keeps the outgoing
|
|
16
|
-
* bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1}
|
|
17
|
+
* - **Drain** — {@link TailDrainGate} keeps the outgoing root serving renewals/replays for `T_drain` while
|
|
18
|
+
* bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1} naming the new tail.
|
|
17
19
|
* - **Jittered re-registration** — {@link planReRegistration} / {@link planReRegistrationWave} schedule a
|
|
18
|
-
* subscriber's
|
|
20
|
+
* subscriber's follow of the new tail over `T_rejoin_jitter` (the cohort-topic {@link RejoinJitter}),
|
|
19
21
|
* carrying its existing `lastRevision` (revisions are continuous across rotations).
|
|
20
|
-
* - **Buffer-to-checkpoint handoff** — {@link buildRotationHandoffCheckpoint} folds the outgoing
|
|
22
|
+
* - **Buffer-to-checkpoint handoff** — {@link buildRotationHandoffCheckpoint} folds the outgoing root's
|
|
21
23
|
* replay buffer into a final {@link CheckpointSummary} covering `[lastCheckpoint.toRevision + 1,
|
|
22
24
|
* rotationRevision]`, the **only** state migrated across a rotation; {@link applyRotationHandoff} lands it
|
|
23
|
-
* at the new
|
|
25
|
+
* at the new root so a `ResumeV1` spanning the rotation is recoverable.
|
|
24
26
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* state migrates; the new tree rebuilds via re-registration). It needs no code here.
|
|
27
|
+
* Tiers below the root do not drain on a rotation: only the old root stops receiving commits and releases its
|
|
28
|
+
* state after `T_drain`. It needs no code here.
|
|
28
29
|
*
|
|
29
30
|
* Coordination with [reactivity-backfill-resume-checkpoints]: that ticket owns the `ResumeReplyV1.TailRotated`
|
|
30
|
-
* variant and the `latestKnownTailId`-staleness classification; this
|
|
31
|
-
* and the rotation *condition*. The new
|
|
31
|
+
* variant and the `latestKnownTailId`-staleness classification; this module produces the handoff checkpoint
|
|
32
|
+
* and the rotation *condition*. The new root's {@link PushState.inheritedCheckpoint} (set by
|
|
32
33
|
* {@link applyRotationHandoff}) is the seam the resume classifier consults to answer a checkpoint-window
|
|
33
|
-
* resume whose span crosses the rotation: `classifyResume`/`serveResume`
|
|
34
|
+
* resume whose span crosses the rotation: `classifyResume`/`serveResume` read it (after the rolling
|
|
34
35
|
* `checkpoint` misses) and serve the inherited summary, so a cross-rotation resume no longer falls to
|
|
35
36
|
* `out_of_window` (`docs/reactivity.md` §Resume, §Tail rotation step 5). The drain-window redirect a new
|
|
36
37
|
* subscription receives, {@link RotationRedirectV1}, is serialized by {@link validateRotationRedirectV1} and
|
|
37
38
|
* rides the recover reply envelope as `kind: "rotated"` ({@link import("./recover.js").RecoverReplyV1}).
|
|
38
39
|
*/
|
|
39
|
-
import {
|
|
40
|
-
import { createRingHash } from "../cohort-topic/ring-hash.js";
|
|
40
|
+
import { b64urlToBytes } from "../cohort-topic/wire/codec.js";
|
|
41
41
|
import { BLOCK_FILL_SIZE_DEFAULT, T_DRAIN_MS, WARM_THRESHOLD_DEFAULT } from "./config.js";
|
|
42
42
|
import { buildCheckpointSummary } from "./checkpoint.js";
|
|
43
|
-
import { reactivityTopicId } from "./topic-anchor.js";
|
|
44
43
|
import { asObject, b64urlField, failWire, reqIntInRange, reqString, requireV1 } from "./wire-validate.js";
|
|
45
44
|
// --- pre-announce + subscriber-side detection --------------------------------
|
|
46
45
|
/**
|
|
@@ -53,17 +52,26 @@ export function buildRotationHint(newTailId, fillingRevision) {
|
|
|
53
52
|
return { newTailId, effectiveAtRevision: fillingRevision + 1 };
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
56
|
-
* Detect tail rotation for a subscriber
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
55
|
+
* Detect tail rotation for a subscriber following `followed.tailId` from a delivered notification. Rotation
|
|
56
|
+
* is signaled when the delivered `tailId` **or** the `rotationHint.newTailId` differs from it
|
|
57
|
+
* (`docs/reactivity.md` §Tail rotation). An already-rotated delivery (different `tailId`) takes precedence
|
|
58
|
+
* over a pre-announce.
|
|
59
|
+
*
|
|
60
|
+
* A differing `tailId` at a revision at or below `followed.newestRevision` is **not** a rotation: the
|
|
61
|
+
* notification was announced at a tail the subscriber has already moved past. The old and the new root are
|
|
62
|
+
* different machines delivering independently, so the last notification announced at the old tail can arrive
|
|
63
|
+
* after the subscriber followed the new one; without the revision check it would read as a rotation back to
|
|
64
|
+
* the old tail and cost a registration at a root that announces nothing further.
|
|
60
65
|
*/
|
|
61
|
-
export function detectRotation(
|
|
62
|
-
if (n.tailId !==
|
|
63
|
-
|
|
66
|
+
export function detectRotation(followed, n) {
|
|
67
|
+
if (n.tailId !== followed.tailId) {
|
|
68
|
+
if (n.revision <= followed.newestRevision) {
|
|
69
|
+
return { rotated: false, preAnnounced: false };
|
|
70
|
+
}
|
|
71
|
+
// The delivered notification was announced at the *new* root already — a hard rotation, not a pre-announce.
|
|
64
72
|
return { rotated: true, newTailId: n.tailId, preAnnounced: false };
|
|
65
73
|
}
|
|
66
|
-
if (n.rotationHint !== undefined && n.rotationHint.newTailId !==
|
|
74
|
+
if (n.rotationHint !== undefined && n.rotationHint.newTailId !== followed.tailId) {
|
|
67
75
|
return { rotated: true, newTailId: n.rotationHint.newTailId, preAnnounced: true };
|
|
68
76
|
}
|
|
69
77
|
return { rotated: false, preAnnounced: false };
|
|
@@ -142,8 +150,8 @@ export function validateRotationRedirectV1(value) {
|
|
|
142
150
|
};
|
|
143
151
|
}
|
|
144
152
|
/**
|
|
145
|
-
* The outgoing
|
|
146
|
-
* serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new
|
|
153
|
+
* The outgoing root's drain state machine. For `T_drain` after a rotation it accepts **renewals** and
|
|
154
|
+
* serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new root;
|
|
147
155
|
* after `T_drain` it reports `drained` for everything (the subscriber re-registers from `d_max`).
|
|
148
156
|
*/
|
|
149
157
|
export class TailDrainGate {
|
|
@@ -157,13 +165,11 @@ export class TailDrainGate {
|
|
|
157
165
|
}
|
|
158
166
|
this.rotatedAt = init.rotatedAt;
|
|
159
167
|
this.tDrainMs = tDrainMs;
|
|
160
|
-
const hash = init.hash ?? createRingHash();
|
|
161
|
-
const newTopicId = bytesToB64url(reactivityTopicId(b64urlToBytes(init.newTailId), hash));
|
|
162
168
|
this.redirect = {
|
|
163
169
|
v: 1,
|
|
164
170
|
result: "rotated",
|
|
165
171
|
newTailId: init.newTailId,
|
|
166
|
-
newTopicId,
|
|
172
|
+
newTopicId: init.topicId,
|
|
167
173
|
effectiveAtRevision: init.effectiveAtRevision,
|
|
168
174
|
};
|
|
169
175
|
}
|
|
@@ -181,7 +187,7 @@ export class TailDrainGate {
|
|
|
181
187
|
}
|
|
182
188
|
/**
|
|
183
189
|
* Classify an inbound request. Within the drain window: `new_subscribe` → redirect, `renew`/`replay` →
|
|
184
|
-
* serve. After the window: `drained` (the old
|
|
190
|
+
* serve. After the window: `drained` (the old root has released its forwarder state).
|
|
185
191
|
*/
|
|
186
192
|
classify(op, now) {
|
|
187
193
|
if (!this.isDraining(now)) {
|
|
@@ -190,26 +196,20 @@ export class TailDrainGate {
|
|
|
190
196
|
return op === "new_subscribe" ? { kind: "redirect", redirect: this.redirect } : { kind: "serve" };
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
|
-
/** Resolve `(newTailId, newTopicId)` raw bytes for a rotation target. */
|
|
194
|
-
function resolveRotationTarget(target) {
|
|
195
|
-
const newTailId = b64urlToBytes(target.hint.newTailId);
|
|
196
|
-
const newTopicId = reactivityTopicId(newTailId, target.hash ?? createRingHash());
|
|
197
|
-
return { newTailId, newTopicId };
|
|
198
|
-
}
|
|
199
199
|
/**
|
|
200
|
-
* Plan **one** subscriber's
|
|
201
|
-
* `
|
|
202
|
-
*
|
|
203
|
-
*
|
|
200
|
+
* Plan **one** subscriber's follow of the moved root: carry the hint's `newTailId` and the subscriber's
|
|
201
|
+
* `lastRevision`, and draw a jittered `fireAt` over `T_rejoin_jitter` via the cohort-topic
|
|
202
|
+
* {@link RejoinJitter} (`scheduleRejoin` — a uniform offset, decorrelating this subscriber's re-join from
|
|
203
|
+
* its peers). Only a registration at the root sends anything when the plan fires; one below the root
|
|
204
|
+
* updates its root key locally.
|
|
204
205
|
*/
|
|
205
206
|
export function planReRegistration(opts) {
|
|
206
|
-
|
|
207
|
-
return { newTailId, newTopicId, lastRevision: opts.lastRevision, fireAt: opts.jitter.scheduleRejoin(opts.now) };
|
|
207
|
+
return { newTailId: b64urlToBytes(opts.hint.newTailId), lastRevision: opts.lastRevision, fireAt: opts.jitter.scheduleRejoin(opts.now) };
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
|
-
* Plan a **whole wave** of subscribers'
|
|
210
|
+
* Plan a **whole wave** of subscribers' follows of the moved root. Uses the
|
|
211
211
|
* {@link RejoinJitter.scheduleWave} hard-bound staggering so any `T_rejoin_jitter`-long window holds at
|
|
212
|
-
* most the injected jitter's `capPromote` arrivals — the new
|
|
212
|
+
* most the injected jitter's `capPromote` arrivals — the new root never sees more than
|
|
213
213
|
* `capPromote / T_rejoin_jitter` re-registrations per second.
|
|
214
214
|
*
|
|
215
215
|
* **Caller contract:** rotation is governed by the *fast-promote* bound, so the host MUST build this `jitter`
|
|
@@ -219,12 +219,12 @@ export function planReRegistration(opts) {
|
|
|
219
219
|
* (`docs/reactivity.md` §Tail rotation rotation-cost). Returns one plan per subscriber, ascending by `fireAt`.
|
|
220
220
|
*/
|
|
221
221
|
export function planReRegistrationWave(opts) {
|
|
222
|
-
const
|
|
222
|
+
const newTailId = b64urlToBytes(opts.hint.newTailId);
|
|
223
223
|
const fireAts = opts.jitter.scheduleWave(opts.subscribers.length, opts.now);
|
|
224
|
-
return opts.subscribers.map((s, i) => ({ newTailId,
|
|
224
|
+
return opts.subscribers.map((s, i) => ({ newTailId, lastRevision: s.lastRevision, fireAt: fireAts[i] }));
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
|
-
* Fold the outgoing
|
|
227
|
+
* Fold the outgoing root's replay buffer into the final {@link CheckpointSummary} handed to the new root
|
|
228
228
|
* (`docs/reactivity.md` §Tail rotation step 5 — the **only** state migration across a rotation). The
|
|
229
229
|
* handoff covers `[lastCheckpoint.toRevision + 1, rotationRevision]`: the revisions still live in the
|
|
230
230
|
* replay ring (above the rolling checkpoint's high edge) up to the rotation revision. Returns `undefined`
|
|
@@ -250,10 +250,10 @@ export function buildRotationHandoffCheckpoint(state, opts = {}) {
|
|
|
250
250
|
return { checkpoint, rotationRevision };
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
|
-
* Land a {@link RotationHandoff} at the new
|
|
254
|
-
* `ResumeV1` whose span crosses the rotation is recoverable from the new
|
|
253
|
+
* Land a {@link RotationHandoff} at the new root's {@link PushState}: record the inherited checkpoint so a
|
|
254
|
+
* `ResumeV1` whose span crosses the rotation is recoverable from the new root (the new root "holds the old
|
|
255
255
|
* checkpoint", `docs/reactivity.md` §Tail rotation step 5). The handoff is a one-time migration — it does
|
|
256
|
-
* not feed the new
|
|
256
|
+
* not feed the new root's rolling checkpoint (that rolls from the new root's own replay-ring eviction).
|
|
257
257
|
*/
|
|
258
258
|
export function applyRotationHandoff(newTailState, handoff) {
|
|
259
259
|
newTailState.adoptRotationCheckpoint(handoff.checkpoint);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.js","sourceRoot":"","sources":["../../../src/reactivity/rotation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rotation.js","sourceRoot":"","sources":["../../../src/reactivity/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IACtD,MAAM,IAAI,GAAG,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/E,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACjF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAuB,EAAE,OAAwB;IACrF,YAAY,CAAC,uBAAuB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,gBAAgB,CAAC,OAA0B,EAAE,QAAgB;IAC5E,OAAO,QAAQ,IAAI,OAAO,CAAC,YAAY,IAAI,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC;AAC3E,CAAC"}
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
* Reactivity — subscriber-side subscription state (`docs/reactivity.md` §Subscription).
|
|
3
3
|
*
|
|
4
4
|
* Subscribing to a collection is an **ordinary cohort-topic registration** at tier T3 with a reactivity
|
|
5
|
-
* `appPayload`: `topicId = H(
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* `appPayload`: `topicId = H(collectionId ‖ "reactivity")` (stable for the collection's life), the tail
|
|
6
|
+
* block's routing key as the topic's `rootKey`, the configured TTL (Edge 60 s / Core 90 s), and the
|
|
7
|
+
* cohort-topic walk-toward-root / willingness / promotion / TTL-renewal all reused unchanged. This module
|
|
8
|
+
* owns only the subscriber-side bookkeeping struct and the `appPayload` builder; the db-p2p subscription
|
|
9
|
+
* manager drives the cohort-topic `RegisterV1`.
|
|
9
10
|
*
|
|
10
|
-
* `tailIdAtAttach` is the
|
|
11
|
-
*
|
|
11
|
+
* The payload's `tailIdAtAttach` is the tail at *that registration*; the subscriber itself keeps the latest
|
|
12
|
+
* tail it has followed (`tail` below), which is what detects a rotation (a delivered `tailId` or a
|
|
13
|
+
* `rotationHint` naming another tail) and what a resume names as `latestKnownTailId`. `cohortEpoch` detects
|
|
14
|
+
* membership drift within the topic.
|
|
12
15
|
*/
|
|
13
16
|
import { type SubscribeAppPayloadV1 } from "./wire.js";
|
|
14
17
|
/** Subscriber-side live state for one active subscription (`docs/reactivity.md` §Subscriber-side state). */
|
|
15
18
|
export interface ActiveSubscription {
|
|
16
19
|
/** Stable collection identity. */
|
|
17
20
|
readonly collectionId: Uint8Array;
|
|
18
|
-
/**
|
|
21
|
+
/** The collection's topic id — `H(collectionId ‖ "reactivity")`, stable for the collection's life. */
|
|
19
22
|
readonly topicId: Uint8Array;
|
|
20
|
-
/**
|
|
21
|
-
|
|
23
|
+
/** The latest tail block the subscription has followed: the topic's current root key, and what detects a rotation. */
|
|
24
|
+
tail: Uint8Array;
|
|
22
25
|
/** Serving cohort member. */
|
|
23
26
|
primary: Uint8Array;
|
|
24
27
|
/** Warm-failover cohort members. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/reactivity/subscription.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/reactivity/subscription.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElF,4GAA4G;AAC5G,MAAM,WAAW,kBAAkB;IAClC,kCAAkC;IAClC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAClC,sGAAsG;IACtG,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,sHAAsH;IACtH,IAAI,EAAE,UAAU,CAAC;IACjB,6BAA6B;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,oCAAoC;IACpC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,iDAAiD;IACjD,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,mDAAmD;IACnD,WAAW,EAAE,UAAU,CAAC;IACxB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,qBAAqB,CAQvF;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,UAAU,CAE5E"}
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
* Reactivity — subscriber-side subscription state (`docs/reactivity.md` §Subscription).
|
|
3
3
|
*
|
|
4
4
|
* Subscribing to a collection is an **ordinary cohort-topic registration** at tier T3 with a reactivity
|
|
5
|
-
* `appPayload`: `topicId = H(
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* `appPayload`: `topicId = H(collectionId ‖ "reactivity")` (stable for the collection's life), the tail
|
|
6
|
+
* block's routing key as the topic's `rootKey`, the configured TTL (Edge 60 s / Core 90 s), and the
|
|
7
|
+
* cohort-topic walk-toward-root / willingness / promotion / TTL-renewal all reused unchanged. This module
|
|
8
|
+
* owns only the subscriber-side bookkeeping struct and the `appPayload` builder; the db-p2p subscription
|
|
9
|
+
* manager drives the cohort-topic `RegisterV1`.
|
|
9
10
|
*
|
|
10
|
-
* `tailIdAtAttach` is the
|
|
11
|
-
*
|
|
11
|
+
* The payload's `tailIdAtAttach` is the tail at *that registration*; the subscriber itself keeps the latest
|
|
12
|
+
* tail it has followed (`tail` below), which is what detects a rotation (a delivered `tailId` or a
|
|
13
|
+
* `rotationHint` naming another tail) and what a resume names as `latestKnownTailId`. `cohortEpoch` detects
|
|
14
|
+
* membership drift within the topic.
|
|
12
15
|
*/
|
|
13
16
|
import { encodeSubscribeAppPayload } from "./wire.js";
|
|
14
17
|
/** Build the validated {@link SubscribeAppPayloadV1} for a subscription. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../src/reactivity/subscription.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../src/reactivity/subscription.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,yBAAyB,EAA8B,MAAM,WAAW,CAAC;AAsClF,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC/D,OAAO;QACN,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC;QACtC,aAAa,EAAE,MAAM,CAAC,aAAa;KACnC,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC/D,OAAO,yBAAyB,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC"}
|