@peerbit/shared-log 15.0.0 → 16.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/src/checked-prune.d.ts.map +1 -1
  2. package/dist/src/checked-prune.js +12 -0
  3. package/dist/src/checked-prune.js.map +1 -1
  4. package/dist/src/index.d.ts +7 -13
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +81 -598
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/instance-lifecycle.d.ts.map +1 -1
  9. package/dist/src/instance-lifecycle.js +9 -0
  10. package/dist/src/instance-lifecycle.js.map +1 -1
  11. package/dist/src/peer-session.d.ts.map +1 -1
  12. package/dist/src/peer-session.js +9 -0
  13. package/dist/src/peer-session.js.map +1 -1
  14. package/dist/src/pid.d.ts +0 -2
  15. package/dist/src/pid.d.ts.map +1 -1
  16. package/dist/src/pid.js +0 -5
  17. package/dist/src/pid.js.map +1 -1
  18. package/dist/src/replication-announcement.d.ts +3 -106
  19. package/dist/src/replication-announcement.d.ts.map +1 -1
  20. package/dist/src/replication-announcement.js +0 -521
  21. package/dist/src/replication-announcement.js.map +1 -1
  22. package/dist/src/replication-info-v2-receive.d.ts +14 -43
  23. package/dist/src/replication-info-v2-receive.d.ts.map +1 -1
  24. package/dist/src/replication-info-v2-receive.js +24 -199
  25. package/dist/src/replication-info-v2-receive.js.map +1 -1
  26. package/dist/src/replication-info-v2-send.d.ts +0 -1
  27. package/dist/src/replication-info-v2-send.d.ts.map +1 -1
  28. package/dist/src/replication-info-v2-send.js +0 -6
  29. package/dist/src/replication-info-v2-send.js.map +1 -1
  30. package/dist/src/replication.d.ts +0 -1
  31. package/dist/src/replication.d.ts.map +1 -1
  32. package/dist/src/replication.js +2 -17
  33. package/dist/src/replication.js.map +1 -1
  34. package/dist/src/role.d.ts +0 -4
  35. package/dist/src/role.d.ts.map +1 -1
  36. package/dist/src/role.js +0 -9
  37. package/dist/src/role.js.map +1 -1
  38. package/dist/src/sync/factory.d.ts +0 -1
  39. package/dist/src/sync/factory.d.ts.map +1 -1
  40. package/dist/src/sync/factory.js +20 -36
  41. package/dist/src/sync/factory.js.map +1 -1
  42. package/package.json +8 -8
  43. package/src/checked-prune.ts +12 -0
  44. package/src/index.ts +104 -817
  45. package/src/instance-lifecycle.ts +9 -0
  46. package/src/peer-session.ts +9 -0
  47. package/src/pid.ts +0 -6
  48. package/src/replication-announcement.ts +8 -739
  49. package/src/replication-info-v2-receive.ts +25 -271
  50. package/src/replication-info-v2-send.ts +0 -7
  51. package/src/replication.ts +1 -20
  52. package/src/role.ts +0 -13
  53. package/src/sync/factory.ts +24 -38
@@ -66,10 +66,19 @@ export class InstanceLifecycle {
66
66
  // code. Incremented synchronously with leader-cache invalidation so the
67
67
  // handler can detect whether its pre-join plan needs one fresh
68
68
  // post-persist audit.
69
+ //
70
+ // PERMANENT (fence census closed NO-GO 2026-08-12): a sub-generation
71
+ // WITHIN one lifecycle — it advances while the lifecycle identity is
72
+ // deliberately unchanged, so an identity/session token cannot tell a
73
+ // pre-invalidation plan from a post-invalidation one.
69
74
  public _receiveOwnershipRevision = 0;
70
75
  // Count of ownership-changing range mutations from queue admission
71
76
  // through settlement, including mutations already pending when a receive
72
77
  // starts.
78
+ //
79
+ // PERMANENT (fence census closed NO-GO 2026-08-12): a concurrency-DEPTH
80
+ // refcount, not a staleness token — identity answers "which generation
81
+ // started this?", never "how many mutation lanes are open right now?".
73
82
  public _receiveOwnershipMutationAdmissions = 0;
74
83
 
75
84
  // ---- stage 4: physically owned controllers (moved from SharedLog) ----
@@ -131,6 +131,11 @@ export class PeerSessionRegistry {
131
131
  // peer stays subscribed), and it must also fence a peer that never had a
132
132
  // session. Unlike sessions this map IS cleared at _close (see
133
133
  // clearReceiveEpochsForClose) and replaced at open.
134
+ //
135
+ // PERMANENT (fence census closed NO-GO 2026-08-12): the per-PEER lifetime
136
+ // above is the whole mechanism — a session token would rotate at exactly
137
+ // the moments this map must survive, and could not fence a session-less
138
+ // peer at all.
134
139
  _replicationInfoReceiveEpochByPeer!: Map<string, object>;
135
140
  // Moved from SharedLog (fence B6, same name — the sanctioned file-to-file
136
141
  // ratchet move). Refcount of in-flight destructive peer cleanups: while
@@ -140,6 +145,10 @@ export class PeerSessionRegistry {
140
145
  // reconnect may rotate the session; a fresh session with a zero gate
141
146
  // would reopen receive admission mid-drain. The map instance is replaced
142
147
  // only at open (resetForOpen) and cleared in place at _close.
148
+ //
149
+ // PERMANENT (fence census closed NO-GO 2026-08-12): both structural
150
+ // reasons at once — a concurrency-DEPTH refcount whose per-PEER lifetime
151
+ // deliberately spans the session rotation a reconnect causes mid-drain.
143
152
  _receiveCleanupGateByPeer!: Map<string, number>;
144
153
  // Moved from SharedLog (fence B5, same name). Peers whose replication-info
145
154
  // is fenced: added when a departure/unsubscribe rotation or a reconnect
package/src/pid.ts CHANGED
@@ -3,8 +3,6 @@ const MIN_MEMORY_HEADROOM_BALANCE_SCALER = 0.25;
3
3
  export class PIDReplicationController {
4
4
  integral!: number;
5
5
  prevError!: number;
6
- prevMemoryUsage!: number;
7
- prevTotalFactor!: number;
8
6
  kp: number;
9
7
  ki: number;
10
8
  kd: number;
@@ -42,9 +40,6 @@ export class PIDReplicationController {
42
40
  let { memoryUsage, totalFactor, peerCount, cpuUsage, currentFactor } =
43
41
  properties;
44
42
 
45
- this.prevTotalFactor = totalFactor;
46
- this.prevMemoryUsage = memoryUsage;
47
-
48
43
  const estimatedTotalSize =
49
44
  currentFactor > 0 ? memoryUsage / currentFactor : 1e5;
50
45
 
@@ -238,6 +233,5 @@ export class PIDReplicationController {
238
233
  reset() {
239
234
  this.prevError = 0;
240
235
  this.integral = 0;
241
- this.prevMemoryUsage = 0;
242
236
  }
243
237
  }