@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.
Files changed (117) hide show
  1. package/dist/src/cohort-topic/addressing.d.ts +46 -6
  2. package/dist/src/cohort-topic/addressing.d.ts.map +1 -1
  3. package/dist/src/cohort-topic/addressing.js +58 -18
  4. package/dist/src/cohort-topic/addressing.js.map +1 -1
  5. package/dist/src/cohort-topic/member-engine.d.ts +21 -1
  6. package/dist/src/cohort-topic/member-engine.d.ts.map +1 -1
  7. package/dist/src/cohort-topic/member-engine.js +39 -9
  8. package/dist/src/cohort-topic/member-engine.js.map +1 -1
  9. package/dist/src/cohort-topic/membership/publisher.js +1 -1
  10. package/dist/src/cohort-topic/membership/publisher.js.map +1 -1
  11. package/dist/src/cohort-topic/membership/source.d.ts +4 -0
  12. package/dist/src/cohort-topic/membership/source.d.ts.map +1 -1
  13. package/dist/src/cohort-topic/membership/source.js +4 -0
  14. package/dist/src/cohort-topic/membership/source.js.map +1 -1
  15. package/dist/src/cohort-topic/membership/verifier.d.ts +51 -9
  16. package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -1
  17. package/dist/src/cohort-topic/membership/verifier.js +138 -46
  18. package/dist/src/cohort-topic/membership/verifier.js.map +1 -1
  19. package/dist/src/cohort-topic/ports.d.ts +85 -14
  20. package/dist/src/cohort-topic/ports.d.ts.map +1 -1
  21. package/dist/src/cohort-topic/ports.js +1 -1
  22. package/dist/src/cohort-topic/ports.js.map +1 -1
  23. package/dist/src/cohort-topic/registration/renewal.d.ts +26 -5
  24. package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
  25. package/dist/src/cohort-topic/registration/renewal.js +71 -21
  26. package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
  27. package/dist/src/cohort-topic/service.d.ts +34 -2
  28. package/dist/src/cohort-topic/service.d.ts.map +1 -1
  29. package/dist/src/cohort-topic/service.js +86 -28
  30. package/dist/src/cohort-topic/service.js.map +1 -1
  31. package/dist/src/cohort-topic/sig/payloads.d.ts +5 -1
  32. package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -1
  33. package/dist/src/cohort-topic/sig/payloads.js +6 -1
  34. package/dist/src/cohort-topic/sig/payloads.js.map +1 -1
  35. package/dist/src/cohort-topic/sig/threshold.d.ts +29 -4
  36. package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -1
  37. package/dist/src/cohort-topic/sig/threshold.js +39 -7
  38. package/dist/src/cohort-topic/sig/threshold.js.map +1 -1
  39. package/dist/src/cohort-topic/walk.d.ts +19 -4
  40. package/dist/src/cohort-topic/walk.d.ts.map +1 -1
  41. package/dist/src/cohort-topic/walk.js +29 -6
  42. package/dist/src/cohort-topic/walk.js.map +1 -1
  43. package/dist/src/cohort-topic/willingness.d.ts +17 -1
  44. package/dist/src/cohort-topic/willingness.d.ts.map +1 -1
  45. package/dist/src/cohort-topic/willingness.js +18 -3
  46. package/dist/src/cohort-topic/willingness.js.map +1 -1
  47. package/dist/src/cohort-topic/wire/index.d.ts +1 -1
  48. package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
  49. package/dist/src/cohort-topic/wire/index.js +1 -1
  50. package/dist/src/cohort-topic/wire/index.js.map +1 -1
  51. package/dist/src/cohort-topic/wire/payloads.d.ts +14 -0
  52. package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -1
  53. package/dist/src/cohort-topic/wire/payloads.js +20 -0
  54. package/dist/src/cohort-topic/wire/payloads.js.map +1 -1
  55. package/dist/src/cohort-topic/wire/primitives.d.ts +8 -0
  56. package/dist/src/cohort-topic/wire/primitives.d.ts.map +1 -1
  57. package/dist/src/cohort-topic/wire/primitives.js +24 -4
  58. package/dist/src/cohort-topic/wire/primitives.js.map +1 -1
  59. package/dist/src/cohort-topic/wire/types.d.ts +37 -0
  60. package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
  61. package/dist/src/cohort-topic/wire/validate.d.ts +9 -1
  62. package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
  63. package/dist/src/cohort-topic/wire/validate.js +23 -4
  64. package/dist/src/cohort-topic/wire/validate.js.map +1 -1
  65. package/dist/src/reactivity/config.d.ts +9 -10
  66. package/dist/src/reactivity/config.d.ts.map +1 -1
  67. package/dist/src/reactivity/config.js +9 -9
  68. package/dist/src/reactivity/config.js.map +1 -1
  69. package/dist/src/reactivity/index.d.ts +4 -3
  70. package/dist/src/reactivity/index.d.ts.map +1 -1
  71. package/dist/src/reactivity/index.js +4 -3
  72. package/dist/src/reactivity/index.js.map +1 -1
  73. package/dist/src/reactivity/rotation.d.ts +73 -57
  74. package/dist/src/reactivity/rotation.d.ts.map +1 -1
  75. package/dist/src/reactivity/rotation.js +54 -54
  76. package/dist/src/reactivity/rotation.js.map +1 -1
  77. package/dist/src/reactivity/subscription.d.ts +12 -9
  78. package/dist/src/reactivity/subscription.d.ts.map +1 -1
  79. package/dist/src/reactivity/subscription.js +9 -6
  80. package/dist/src/reactivity/subscription.js.map +1 -1
  81. package/dist/src/reactivity/topic-anchor.d.ts +36 -31
  82. package/dist/src/reactivity/topic-anchor.d.ts.map +1 -1
  83. package/dist/src/reactivity/topic-anchor.js +41 -39
  84. package/dist/src/reactivity/topic-anchor.js.map +1 -1
  85. package/dist/src/reactivity/verify.d.ts +26 -9
  86. package/dist/src/reactivity/verify.d.ts.map +1 -1
  87. package/dist/src/reactivity/verify.js +26 -11
  88. package/dist/src/reactivity/verify.js.map +1 -1
  89. package/dist/src/reactivity/wire.d.ts +1 -1
  90. package/dist/src/reactivity/wire.d.ts.map +1 -1
  91. package/dist/src/transactor/change-notifier.d.ts +1 -1
  92. package/package.json +1 -1
  93. package/src/cohort-topic/addressing.ts +83 -23
  94. package/src/cohort-topic/member-engine.ts +77 -8
  95. package/src/cohort-topic/membership/publisher.ts +1 -1
  96. package/src/cohort-topic/membership/source.ts +4 -0
  97. package/src/cohort-topic/membership/verifier.ts +169 -51
  98. package/src/cohort-topic/ports.ts +87 -15
  99. package/src/cohort-topic/registration/renewal.ts +87 -24
  100. package/src/cohort-topic/service.ts +157 -35
  101. package/src/cohort-topic/sig/payloads.ts +7 -2
  102. package/src/cohort-topic/sig/threshold.ts +41 -7
  103. package/src/cohort-topic/walk.ts +46 -9
  104. package/src/cohort-topic/willingness.ts +34 -3
  105. package/src/cohort-topic/wire/index.ts +1 -0
  106. package/src/cohort-topic/wire/payloads.ts +21 -0
  107. package/src/cohort-topic/wire/primitives.ts +26 -4
  108. package/src/cohort-topic/wire/types.ts +37 -0
  109. package/src/cohort-topic/wire/validate.ts +26 -3
  110. package/src/reactivity/config.ts +10 -10
  111. package/src/reactivity/index.ts +4 -3
  112. package/src/reactivity/rotation.ts +86 -78
  113. package/src/reactivity/subscription.ts +12 -9
  114. package/src/reactivity/topic-anchor.ts +42 -45
  115. package/src/reactivity/verify.ts +36 -17
  116. package/src/reactivity/wire.ts +1 -1
  117. package/src/transactor/change-notifier.ts +1 -1
@@ -1,42 +1,42 @@
1
1
  /**
2
- * Reactivity — tail rotation lifecycle (`docs/reactivity.md` §Rotating tail anchor, §Tail rotation).
2
+ * Reactivity — tail rotation lifecycle (`docs/reactivity.md` §Anchor, §Tail rotation).
3
3
  *
4
- * `topicId = H(tailId ‖ "reactivity")` is derived per emission ({@link reactivityTopicId}). When the tail
5
- * block fills (`block_fill_size` transactions, default 64) a new tail block is born and `tailId` — hence
6
- * `topicId` — changes; the cohort-topic layer treats the new `topicId` as an **entirely new topic** (fresh
7
- * tree, new ring coord). Reactivity manages the subscriber/replay-state migration explicitly. This module
8
- * owns that lifecycle:
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 tail serving renewals/replays for `T_drain` while
16
- * bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1} to the new tree.
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 move to the new `topicId` over `T_rejoin_jitter` (the cohort-topic {@link RejoinJitter}),
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 tail's
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 tail so a `ResumeV1` spanning the rotation is recoverable.
25
+ * at the new root so a `ResumeV1` spanning the rotation is recoverable.
24
26
  *
25
- * Forwarder draining is *emergent*: forwarders under the old tail watch their direct-subscriber count drop
26
- * as subscribers re-register elsewhere and demote naturally per the cohort-topic demotion protocol (no
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 ticket produces the handoff checkpoint
31
- * and the rotation *condition*. The new tail's {@link PushState.inheritedCheckpoint} (set by
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` now read it (after the rolling
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 tree has rotated (delivered tail differs) or a rotation is pre-announced. */
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 `tailIdAtAttach`, but the
59
- * notification's `rotationHint.newTailId` names a different successor. (False when the delivered tail
60
- * already differs — the tree has *already* migrated.)
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 attached at `tailIdAtAttach` (base64url) from a delivered
66
- * notification. Rotation is signaled when the delivered `tailId` **or** the `rotationHint.newTailId`
67
- * differs from `tailIdAtAttach` (`docs/reactivity.md` §Rotating tail anchor). An already-rotated delivery
68
- * (different `tailId`) takes precedence over a pre-announce.
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(tailIdAtAttach: string, n: Pick<NotificationV1, "tailId" | "rotationHint">): RotationDetection;
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
- /** Transactions per block before the tail rotates (default {@link BLOCK_FILL_SIZE_DEFAULT}). */
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 rotated tree (`docs/reactivity.md` §Tail rotation step 2). Unlike the
136
- * cohort-topic tier-based `Promoted`, this redirects to an entirely **new topic** — the new tail's tree at
137
- * `coord_0(_, newTopicId)` — so it carries the successor's `newTailId` + derived `newTopicId`.
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 topic anchor rotated to, base64url. */
161
+ /** New tail block id the root moved to, base64url — the new root key. */
143
162
  readonly newTailId: string;
144
- /** `H(newTailId ‖ "reactivity")` — the new tree's topic id, base64url (the redirect target). */
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 topic rotated to, base64url. */
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 tail's drain state machine. For `T_drain` after a rotation it accepts **renewals** and
187
- * serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new tree;
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 tail has released its forwarder state).
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 re-registration at the rotated tree. */
226
+ /** A subscriber's planned follow of the moved root. */
208
227
  export interface ReRegistrationPlan {
209
- /** New tail block id (raw bytes) to attach under. */
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 re-registration (jittered over `T_rejoin_jitter`). */
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 re-registration at the rotated tree: derive the new `topicId` from the hint's
227
- * `newTailId`, carry the subscriber's `lastRevision`, and draw a jittered `fireAt` over `T_rejoin_jitter`
228
- * via the cohort-topic {@link RejoinJitter} (`scheduleRejoin` — a uniform offset, decorrelating this
229
- * subscriber's re-join from its peers).
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' re-registrations at the rotated tree. Uses the
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 tail never sees more than
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 tail to the new tail on rotation. */
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 tail's replay buffer into the final {@link CheckpointSummary} handed to the new tail
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 tail's {@link PushState}: record the inherited checkpoint so a
275
- * `ResumeV1` whose span crosses the rotation is recoverable from the new tail (the new tail "holds the old
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 tail's rolling checkpoint (that rolls from the new tree's own replay-ring eviction).
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAA0B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,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,0GAA0G;IAC1G,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;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,cAAc,CAAC,GAAG,iBAAiB,CAS5H;AAID,+EAA+E;AAC/E,MAAM,MAAM,eAAe;AAC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Q,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` §Rotating tail anchor, §Tail rotation).
2
+ * Reactivity — tail rotation lifecycle (`docs/reactivity.md` §Anchor, §Tail rotation).
3
3
  *
4
- * `topicId = H(tailId ‖ "reactivity")` is derived per emission ({@link reactivityTopicId}). When the tail
5
- * block fills (`block_fill_size` transactions, default 64) a new tail block is born and `tailId` — hence
6
- * `topicId` — changes; the cohort-topic layer treats the new `topicId` as an **entirely new topic** (fresh
7
- * tree, new ring coord). Reactivity manages the subscriber/replay-state migration explicitly. This module
8
- * owns that lifecycle:
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 tail serving renewals/replays for `T_drain` while
16
- * bouncing *new* subscriptions with a `Promoted`-shaped {@link RotationRedirectV1} to the new tree.
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 move to the new `topicId` over `T_rejoin_jitter` (the cohort-topic {@link RejoinJitter}),
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 tail's
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 tail so a `ResumeV1` spanning the rotation is recoverable.
25
+ * at the new root so a `ResumeV1` spanning the rotation is recoverable.
24
26
  *
25
- * Forwarder draining is *emergent*: forwarders under the old tail watch their direct-subscriber count drop
26
- * as subscribers re-register elsewhere and demote naturally per the cohort-topic demotion protocol (no
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 ticket produces the handoff checkpoint
31
- * and the rotation *condition*. The new tail's {@link PushState.inheritedCheckpoint} (set by
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` now read it (after the rolling
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 { bytesToB64url, b64urlToBytes } from "../cohort-topic/wire/codec.js";
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 attached at `tailIdAtAttach` (base64url) from a delivered
57
- * notification. Rotation is signaled when the delivered `tailId` **or** the `rotationHint.newTailId`
58
- * differs from `tailIdAtAttach` (`docs/reactivity.md` §Rotating tail anchor). An already-rotated delivery
59
- * (different `tailId`) takes precedence over a pre-announce.
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(tailIdAtAttach, n) {
62
- if (n.tailId !== tailIdAtAttach) {
63
- // The delivered notification rides the *new* tree already — a hard rotation, not a pre-announce.
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 !== tailIdAtAttach) {
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 tail's drain state machine. For `T_drain` after a rotation it accepts **renewals** and
146
- * serves **replays**, but bounces **new subscriptions** with a {@link RotationRedirectV1} to the new tree;
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 tail has released its forwarder state).
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 re-registration at the rotated tree: derive the new `topicId` from the hint's
201
- * `newTailId`, carry the subscriber's `lastRevision`, and draw a jittered `fireAt` over `T_rejoin_jitter`
202
- * via the cohort-topic {@link RejoinJitter} (`scheduleRejoin` — a uniform offset, decorrelating this
203
- * subscriber's re-join from its peers).
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
- const { newTailId, newTopicId } = resolveRotationTarget(opts);
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' re-registrations at the rotated tree. Uses the
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 tail never sees more than
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 { newTailId, newTopicId } = resolveRotationTarget(opts);
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, newTopicId, lastRevision: s.lastRevision, fireAt: fireAts[i] }));
224
+ return opts.subscribers.map((s, i) => ({ newTailId, lastRevision: s.lastRevision, fireAt: fireAts[i] }));
225
225
  }
226
226
  /**
227
- * Fold the outgoing tail's replay buffer into the final {@link CheckpointSummary} handed to the new tail
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 tail's {@link PushState}: record the inherited checkpoint so a
254
- * `ResumeV1` whose span crosses the rotation is recoverable from the new tail (the new tail "holds the old
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 tail's rolling checkpoint (that rolls from the new tree's own replay-ring eviction).
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAA0B,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1G,gFAA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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(currentTailId(C) ‖ "reactivity")`, the configured TTL (Edge 60 s / Core 90 s),
6
- * and the cohort-topic walk-toward-root / willingness / promotion / TTL-renewal all reused unchanged.
7
- * This module owns only the subscriber-side bookkeeping struct and the `appPayload` builder; the db-p2p
8
- * subscription manager drives the cohort-topic `RegisterV1`.
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 subscriber-side detector for tail rotation (the whole-tree migration the
11
- * rotation ticket handles); `cohortEpoch` detects membership drift within the topic.
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
- /** Current tail-anchored topic id. */
21
+ /** The collection's topic id — `H(collectionId ‖ "reactivity")`, stable for the collection's life. */
19
22
  readonly topicId: Uint8Array;
20
- /** Tail block id at registration time — detects tail rotation. */
21
- readonly tailIdAtAttach: Uint8Array;
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;;;;;;;;;;;GAWG;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,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;IACpC,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,e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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(currentTailId(C) ‖ "reactivity")`, the configured TTL (Edge 60 s / Core 90 s),
6
- * and the cohort-topic walk-toward-root / willingness / promotion / TTL-renewal all reused unchanged.
7
- * This module owns only the subscriber-side bookkeeping struct and the `appPayload` builder; the db-p2p
8
- * subscription manager drives the cohort-topic `RegisterV1`.
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 subscriber-side detector for tail rotation (the whole-tree migration the
11
- * rotation ticket handles); `cohortEpoch` detects membership drift within the topic.
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;;;;;;;;;;;GAWG;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"}
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"}