nowity 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -635,8 +635,8 @@ Three things follow from it being the database that coordinates:
635
635
  - **Connections are sticky, but only for their lifetime.** A socket lives on one
636
636
  instance; a client that reconnects elsewhere resends its subscriptions and
637
637
  continues its mutation sequence from where the database says it got to.
638
- - **A new instance starts from now.** It resumes at the transaction horizon
639
- rather than replaying history, and its clients are still correct because a
638
+ - **A new instance starts from now.** It resumes from the snapshot its engine
639
+ started in rather than replaying history, and its clients are still correct because a
640
640
  subscription's first answer is a snapshot of the database, not a replay of the
641
641
  stream.
642
642
  - **Retention waits for the slowest live reader.** `nowity.nowity_prune_outbox` deletes
@@ -1038,13 +1038,38 @@ Off by default. `true`, or a function decided once per connection at its hello
1038
1038
  `timing` on every `mutation-result` — `receivedAt` (on the socket), `startedAt`
1039
1039
  (its turn in the connection's queue), `committedAt`, `sentAt` — and on every
1040
1040
  `tx` — `writtenAt` (its own earliest outbox row, the *database's* clock),
1041
- `readAt` (handed over by the change source), `fanOutAt`, `sentAt`. The recorder
1041
+ `readAt` (handed over by the change source; for the `tx` that carries the
1042
+ writer's own data with the ack, the commit), `fanOutAt`, `sentAt`. The recorder
1042
1043
  keeps them on the mutation (`meta.server`, and `meta.push` with `meta.dataAt`
1043
1044
  from the first data that included it), and `mutationPhases(record)` lays the
1044
1045
  whole round on one axis: sent → received → started → written → committed →
1045
1046
  answered → read → fan-out → pushed → data, client times with their ± uncertainty.
1046
1047
  The detail of a mutation in the panel shows exactly that.
1047
1048
 
1049
+ #### Narrowing of a subscription
1050
+
1051
+ ```ts
1052
+ createNowityServer({
1053
+ syncServer: { narrowing: (session) => isAdmin(session.userId) },
1054
+ });
1055
+ ```
1056
+
1057
+ Off by default, decided like `timing`. A connection with narrowing gets
1058
+ `narrowing` (`SubNarrowing`) on every `snapshot` — also the re-snapshots inside a
1059
+ `tx` — and in `tx.narrowing` (`{ subId, narrowing }[]`) whenever a recomputation
1060
+ changed what a subscription reads. It is how the invalidation index sees the
1061
+ subscription, which is what decides what a change costs:
1062
+
1063
+ - `always: true` — the read set is not known, every change recomputes it;
1064
+ - `tables[]` — one entry per table read: `whole: true` means any change to the
1065
+ table recomputes it (`declared: true` = named by `@query({ tables })`), else
1066
+ `columns` + `keys` say it is filed under that many values of those columns;
1067
+ - `narrowed: false` — the server runs with `narrowInvalidation: false`, so the
1068
+ index uses tables only, whatever the keys say.
1069
+
1070
+ Names only: the values a read was keyed by are row data and are never sent.
1071
+ Read it from `onServerMessage`.
1072
+
1048
1073
  ### Escape hatches
1049
1074
 
1050
1075
  `@query({ tables: [...] })` for a query that reads through something the tracker
@@ -1096,15 +1121,23 @@ sees the full `OLD` row — which the WAL does not, unless you opt into
1096
1121
  `bigserial` alone is not a usable cursor: sequence values are handed out before
1097
1122
  commit, so ordering by `seq` can walk past a row whose transaction commits later,
1098
1123
  and `seq > cursor` would then hide it forever. Every outbox row therefore also
1099
- stores `pg_current_xact_id()`, and the reader only consumes rows whose `xid` is
1100
- below `pg_snapshot_xmin(pg_current_snapshot())` — the oldest transaction still in
1101
- flight. That set is fully committed, immutable, and grows as a *prefix* of the `xid`
1102
- order, so a single `xid` is a complete bookmark.
1103
-
1104
- The same property closes the snapshot/stream hole: subscriptions are snapshotted
1105
- only while the stream is quiesced at a known cursor, and everything at or below that
1106
- cursor had already finished, so it is guaranteed visible in the snapshot. Anything
1107
- invisible in the snapshot is above the cursor and gets streamed. Delivery is
1124
+ stores `pg_current_xact_id()`, and the cursor is a *snapshot*
1125
+ (`pg_current_snapshot()`): "every transaction it sees has been delivered". A read
1126
+ returns the rows of the transactions its own statement snapshot sees and the
1127
+ cursor does not (`pg_visible_in_snapshot`), and that snapshot becomes the cursor.
1128
+ Each transaction becomes visible in exactly one such interval, so nothing is
1129
+ skipped and nothing is read twice.
1130
+
1131
+ Up to 1.10 the cursor was the oldest transaction still in flight
1132
+ (`pg_snapshot_xmin`), and one long write transaction anywhere in the database
1133
+ held every change behind it. With the snapshot cursor a transaction in flight is
1134
+ just not seen yet; the rest flows past it and its rows arrive after its commit
1135
+ (scenario 34e).
1136
+
1137
+ The same property closes the snapshot/stream hole: the engine starts from the
1138
+ snapshot its starting state was read in, and every later snapshot sees at least
1139
+ what the cursor sees. Anything a snapshot does not see is not under the cursor
1140
+ and gets streamed. Delivery is
1108
1141
  at-least-once; because patches come from re-running the query and diffing, a replay
1109
1142
  produces an empty diff, so the client observes exactly once.
1110
1143
 
@@ -1128,11 +1161,52 @@ snapshot there: the fan-out, the first answer of a subscription, server-side
1128
1161
  rendering in that process. The engine fans out one batch at a time, so a pool of
1129
1162
  a few connections is plenty.
1130
1163
 
1164
+ ### Parallel fan-out (1.11)
1165
+
1166
+ A batch with a lot to recompute is spread over several snapshots at once:
1167
+ `createNowityServer({ fanOut: { concurrency, minPerSnapshot } })`, default 4
1168
+ snapshots and one per 8 recomputations, so a small batch still takes one. A
1169
+ session is never split between two snapshots — a client never sees half of a
1170
+ transaction — and batches still go out one after another, so the patches of one
1171
+ subscription keep their order. Each snapshot is a connection of the snapshot
1172
+ pool: size the pool to `concurrency` plus whatever subscribes, acks and
1173
+ server-side rendering need alongside.
1174
+
1175
+ ### The writer's data comes with the ack (1.11)
1176
+
1177
+ A mutation reads, in its own transaction and in the same statement that moves
1178
+ `last_mutation_id`, what the capture trigger put in the outbox for it. Right
1179
+ after the commit the engine recomputes the writer's subscriptions those writes
1180
+ can reach and sends them as a `tx` — with `lastMutationId` = the mutation —
1181
+ immediately before `mutation-result`. The client needs nothing new: the `tx`
1182
+ confirms the mutation and drops its optimistic copy, the result resolves the
1183
+ promise. When the stream later carries the same transaction, the writer's
1184
+ subscriptions remember the snapshot the ack read in, see the transaction in it
1185
+ and are skipped (`engine.stats.skipped`); a batch that also carries something
1186
+ newer is recomputed and diffed as usual, so the writer is never sent the same
1187
+ state twice.
1188
+
1189
+ The ack is all or nothing and falls back to the stream when it cannot be
1190
+ complete: a write to a permission table (the invalidation path stays the
1191
+ stream's), a subscribe of the same connection still being evaluated, a change
1192
+ source that cannot say what a transaction wrote (WAL), or `ackWithState: false`.
1193
+ Its snapshots and recomputations are counted apart (`stats.acks`,
1194
+ `ackSnapshots`, `ackEvaluations`). Other clients get the transaction through the
1195
+ stream as before.
1196
+
1197
+ Mutations of one socket no longer queue behind its subscribes: they keep their
1198
+ order among themselves and wait for the socket's `hello`, but a slow subscribe
1199
+ in front of them does not hold them up. The start of a mutation's transaction is
1200
+ one statement instead of three (create-or-lock the client row and stamp the
1201
+ transaction).
1202
+
1131
1203
  ## Known limitations
1132
1204
 
1133
- - **A long-running write transaction stalls the outbox stream** until it finishes
1134
- (read-only transactions do not — they never get an xid). Short transactions, which
1135
- is the normal case, are unaffected. This is the price of the gap-free cursor.
1205
+ - **A long-running write transaction costs the outbox reads index range.** It no
1206
+ longer stalls the stream (1.11), but every read scans the outbox from the oldest
1207
+ xid in flight in its cursor, so a transaction open for minutes makes each read
1208
+ walk the rows written since it began (filtered out by visibility). It also holds
1209
+ retention back, as before.
1136
1210
  - **Incremental view maintenance is naive**: on a relevant change the query is
1137
1211
  re-executed and its result diffed. Correct for any query, O(result size) per
1138
1212
  change. Which subscriptions are *relevant* is now decided by row rather than by
package/dist/client.d.ts CHANGED
@@ -42,7 +42,7 @@ export type { Draft, EntityTx, LocalEntities, LocalTx } from "./client/overlay";
42
42
  export { WebSocketTransport, type WebSocketTransportOptions } from "./client/ws-transport";
43
43
  export { ServerClock, clockSample, type ClockSample, type ClockState, type ServerClockOptions, } from "./client/clock";
44
44
  export type { ClockSyncOptions } from "./client/nowity-client";
45
- export type { MutationTiming, TxTiming } from "./core/protocol";
45
+ export type { MutationTiming, NarrowingTable, SubNarrowing, SubNarrowingUpdate, TxTiming } from "./core/protocol";
46
46
  /**
47
47
  * The recorder behind `client.enableDevtools()`; the panel that shows it is a
48
48
  * separate entry, `nowity/devtools`, loaded only where it is wanted.
@@ -1 +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Ac,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -174,6 +174,8 @@ export interface ServerWelcome {
174
174
  };
175
175
  /** This connection gets {@link MutationTiming} / {@link TxTiming} (the server's `timing` option). */
176
176
  timing?: boolean;
177
+ /** This connection gets {@link SubNarrowing} (the server's `narrowing` option). */
178
+ narrowing?: boolean;
177
179
  }
178
180
  /** Full result of a live query. Replaces whatever the client held for `subId`. */
179
181
  export interface SubSnapshot {
@@ -213,6 +215,42 @@ export interface SubSnapshot {
213
215
  * Absent = none. Replaced, never merged, by a later `mutators` list.
214
216
  */
215
217
  mutators?: DerivedMutator[];
218
+ /** See {@link SubNarrowing}. Only on a connection the server sends narrowing to. */
219
+ narrowing?: SubNarrowing;
220
+ }
221
+ /**
222
+ * How far the server could narrow what one subscription read — which changes
223
+ * can wake it up. A developer panel's view of the invalidation index, never of
224
+ * the data: tables and column names only, no value a read was keyed by.
225
+ *
226
+ * - `always`: the read set is not known, every change recomputes it;
227
+ * - otherwise one entry per table read: `whole` = any change to the table
228
+ * recomputes it (`declared` = named by `@query({ tables })`, which never
229
+ * narrows), else only changes to rows matching one of `keys` values of
230
+ * `columns`.
231
+ *
232
+ * `narrowed: false` on the server means the index ignores the keys (the
233
+ * `narrowInvalidation: false` kill switch): every table is effectively whole.
234
+ */
235
+ export interface SubNarrowing {
236
+ always: boolean;
237
+ narrowed: boolean;
238
+ tables: NarrowingTable[];
239
+ }
240
+ export type NarrowingTable = {
241
+ table: string;
242
+ whole: true;
243
+ declared?: true;
244
+ } | {
245
+ table: string;
246
+ whole: false;
247
+ columns: string[];
248
+ keys: number;
249
+ };
250
+ /** The narrowing of one subscription, replacing whatever it had. */
251
+ export interface SubNarrowingUpdate {
252
+ subId: string;
253
+ narrowing: SubNarrowing;
216
254
  }
217
255
  export interface ServerSnapshot extends SubSnapshot {
218
256
  t: "snapshot";
@@ -291,6 +329,8 @@ export interface ServerTx {
291
329
  revoked?: SubRevoked[];
292
330
  /** Subscriptions whose derived mutators changed, with the whole new list. */
293
331
  mutators?: SubMutators[];
332
+ /** Subscriptions whose {@link SubNarrowing} changed (not re-snapshotted ones — a snapshot carries its own). */
333
+ narrowing?: SubNarrowingUpdate[];
294
334
  }
295
335
  /** The derived mutators of one subscription, replacing whatever it had. */
296
336
  export interface SubMutators {
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/core/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;GASG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,MAAM,WAAW,WAAW;IACxB,CAAC,EAAE,OAAO,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC5B,CAAC,EAAE,WAAW,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAC9B,CAAC,EAAE,aAAa,CA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;AAED,oGAAoG;AACpG,MAAM,WAAW,UAAU;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IACxB,CAAC,EAAE,OAAO,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GACnB,aAAa,GACb,cAAc,GACd,QAAQ,GACR,oBAAoB,GACpB,cAAc,GACd,UAAU,GACV,WAAW,CAAC"}
@@ -92,6 +92,13 @@ export interface TransactionBatch {
92
92
  * means one.
93
93
  */
94
94
  transactions?: number;
95
+ /**
96
+ * Ids of every transaction in the batch, when the source knows them (the
97
+ * outbox does). Lets the engine tell that a subscription it has already
98
+ * recomputed after these transactions committed needs nothing from the
99
+ * batch. Absent means "unknown", which only ever costs a recomputation.
100
+ */
101
+ xids?: string[];
95
102
  events: ChangeEvent[];
96
103
  }
97
104
  /** Field-level upsert for a single entity instance. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,4EAA4E;AAC5E,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEtD,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,K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G;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,QAAQ,CAAC;IACb,sEAAsE;IACtE,MAAM,EAAE,GAAG,CAAC;IACZ,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,yEAAyE;AACzE,MAAM,WAAW,OAAO;IACpB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAElD"}
@@ -1,5 +1,5 @@
1
1
  import type { ChangeSource } from "../change-source/change-source";
2
- import { SyncEngine } from "../sync-engine";
2
+ import { SyncEngine, type SyncEngineOptions } from "../sync-engine";
3
3
  import { NowitySyncServer, type NowitySyncServerOptions } from "../ws-server";
4
4
  import { PresenceTracker, type PresenceOptions } from "../presence";
5
5
  import { SchedulerWorker, type SchedulerOptions } from "../scheduler";
@@ -22,6 +22,10 @@ export interface NowityServerConfig extends NowityRuntimeConfig {
22
22
  syncServer?: Omit<NowitySyncServerOptions, "engine">;
23
23
  /** See {@link SyncEngineOptions.narrowInvalidation}. On unless set. */
24
24
  narrowInvalidation?: boolean;
25
+ /** See {@link SyncEngineOptions.ackWithState}. On unless `false`. */
26
+ ackWithState?: boolean;
27
+ /** See {@link SyncEngineOptions.fanOut}. */
28
+ fanOut?: SyncEngineOptions["fanOut"];
25
29
  /**
26
30
  * Record who is connected, so endpoints can read it through the injectable
27
31
  * {@link Presence} and react to users going offline (`Presence.onOffline`).
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../src/server/api/configure.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,UAAU,EAA0B,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAItE,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE9F,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,CAAC;IACnD,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,UAAU,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;IACrD,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACjC,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2D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,UAAU,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;IACrD,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qEAAqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACjC,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,MAAM,WAAW,YAAa,SAAQ,aAAa;IAC/C,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,sDAAsD;IACtD,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,2DAA2D;IAC3D,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,sEAAsE;IACtE,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAoBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CA+D3E"}
@@ -57,6 +57,8 @@ function createNowityServer(config) {
57
57
  derived: runtime.api.derived,
58
58
  api: { contracts: runtime.api.manifest.contracts, entities: runtime.api.entities },
59
59
  narrowInvalidation: config.narrowInvalidation,
60
+ ackWithState: config.ackWithState,
61
+ fanOut: config.fanOut,
60
62
  ...(presence ? { presence } : {}),
61
63
  onError: config.onError,
62
64
  });
@@ -1,4 +1,4 @@
1
- import type { TransactionBatch } from "../../core/types";
1
+ import type { ChangeEvent, TransactionBatch } from "../../core/types";
2
2
  import type { SnapshotContext } from "../db";
3
3
  export type BatchHandler = (batch: TransactionBatch) => Promise<void>;
4
4
  /**
@@ -9,10 +9,13 @@ export type BatchHandler = (batch: TransactionBatch) => Promise<void>;
9
9
  * WAL can be swapped in later without touching the sync engine.
10
10
  *
11
11
  * Contract every implementation must honour:
12
- * 1. `handler` is called with whole database transactions in commit order —
13
- * one per call, or several committed ones together (the outbox does that
14
- * per read, so the engine takes one snapshot for all of them). A
15
- * transaction is never split across calls.
12
+ * 1. `handler` is called with whole, committed database transactions — one
13
+ * per call, or several together (the outbox does that per read, so the
14
+ * engine takes one snapshot for all of them). A transaction is never split
15
+ * across calls, and one delivered in a later call committed after the ones
16
+ * of an earlier call. Within one call the order is the source's (the
17
+ * outbox orders by xid); the engine recomputes from the database, so it
18
+ * does not depend on it.
16
19
  * 2. `handler` is awaited; no further batch is delivered until it resolves.
17
20
  * 3. Delivery is at-least-once. Duplicates are allowed — the engine recomputes
18
21
  * queries from the database, so replaying a batch produces an empty diff.
@@ -34,6 +37,21 @@ export interface ChangeSource {
34
37
  * one.
35
38
  */
36
39
  readonly attributesWrites?: boolean;
40
+ /**
41
+ * How a mutation can learn, inside its own transaction, which change
42
+ * events it produced — so the engine can recompute the writer's own
43
+ * subscriptions right after the commit and send them with the result,
44
+ * instead of after the round trip through the stream.
45
+ *
46
+ * `sql` is a scalar expression evaluated in the mutation's transaction
47
+ * after its writes; `parse` turns its value into events. Absent, the
48
+ * writer gets its data through the stream like everyone else (logical
49
+ * replication cannot do this: the WAL is only readable after commit).
50
+ */
51
+ readonly ownWrites?: {
52
+ readonly sql: string;
53
+ parse(value: unknown, clientId: string, mutationId: number): ChangeEvent[];
54
+ };
37
55
  startPosition(snap: SnapshotContext): Promise<string>;
38
56
  start(from: string, handler: BatchHandler): Promise<void>;
39
57
  stop(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"change-source.d.ts","sourceRoot":"","sources":["../../../src/server/change-source/change-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAEpC,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB,2EAA2E;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
1
+ {"version":3,"file":"change-source.d.ts","sourceRoot":"","sources":["../../../src/server/change-source/change-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE7C,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE;QACjB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;KAC9E,CAAC;IAEF,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB,2EAA2E;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
@@ -60,20 +60,25 @@ interface OutboxRow {
60
60
  * The interesting part is the read cursor. `seq` alone is not usable: sequence
61
61
  * values are assigned before commit, so ordering by `seq` can walk past a row
62
62
  * whose transaction commits later, and that row would then be filtered out by
63
- * `seq > cursor` forever. Instead the reader only consumes rows whose `xid` is
64
- * strictly below `pg_snapshot_xmin(pg_current_snapshot())` — the oldest
65
- * transaction id still in flight. That set has two properties we need:
63
+ * `seq > cursor` forever. A single `xid` cursor has the same hole for the same
64
+ * reason — xids are handed out at the first write, not at commit.
66
65
  *
67
- * - every transaction in it is committed (nothing below xmin can still be
68
- * running), and no new row can ever appear with such an `xid`;
69
- * - it grows as a *prefix* of the `xid` order, so a single `xid` cursor is a
70
- * complete, gap-free bookmark.
66
+ * The cursor is therefore a *snapshot* (`pg_current_snapshot()`): "every
67
+ * transaction this snapshot sees has been delivered". A read takes the
68
+ * statement's own snapshot and returns the rows of exactly the transactions it
69
+ * sees and the cursor did not. Every transaction becomes visible in exactly one
70
+ * such interval, so nothing is skipped and nothing is read twice, and the new
71
+ * snapshot becomes the cursor.
71
72
  *
72
- * Cost of that guarantee: one long-running *write* transaction anywhere in the
73
- * database stalls the stream until it finishes (read-only transactions do not,
74
- * they never get an xid). For an application with short transactions this is
75
- * fine; if it ever stops being fine, that is the moment to switch to the WAL
76
- * source, which gets true commit ordering from the server.
73
+ * Up to 1.10 the cursor was the transaction horizon (`xmin`) instead, and one
74
+ * long-running *write* transaction anywhere in the database — a scheduler job,
75
+ * a migration, a `psql` session left open — held every change behind it until
76
+ * it finished. With a snapshot cursor a transaction still in flight is simply
77
+ * not seen yet; whatever commits around it flows on, and its own rows arrive
78
+ * in the read after its commit. What such a transaction still costs is index
79
+ * range: the read scans from the oldest in-flight xid of the cursor, so a very
80
+ * long one makes each read walk the rows written since it began (filtered out
81
+ * by visibility, never delivered again).
77
82
  */
78
83
  export declare class OutboxChangeSource implements ChangeSource {
79
84
  readonly name = "outbox";
@@ -88,9 +93,21 @@ export declare class OutboxChangeSource implements ChangeSource {
88
93
  readonly consumerId: string;
89
94
  private readonly pruneIntervalMs;
90
95
  private readonly pruneStaleAfter;
96
+ /** Every transaction this snapshot sees has been delivered. */
91
97
  private cursor;
98
+ /** See {@link hold}. */
99
+ private held;
92
100
  /** Last cursor written to `nowity_consumer`; avoids a write per idle lap. */
93
101
  private publishedCursor;
102
+ /**
103
+ * What the engine may fold into a mutation's own transaction to learn what
104
+ * it wrote: the capture trigger has already put it here, under this
105
+ * transaction's xid.
106
+ */
107
+ readonly ownWrites: {
108
+ sql: string;
109
+ parse: (value: unknown, clientId: string, mutationId: number) => ChangeEvent[];
110
+ };
94
111
  private handler;
95
112
  private listener;
96
113
  private timer;
@@ -115,6 +132,13 @@ export declare class OutboxChangeSource implements ChangeSource {
115
132
  * early.
116
133
  */
117
134
  drain(): Promise<void>;
135
+ /**
136
+ * Stop reading until {@link release}, for tests that need several
137
+ * transactions in one read. Laps still run — `drain()` resolves — they
138
+ * just read nothing.
139
+ */
140
+ hold(): void;
141
+ release(): Promise<void>;
118
142
  private wake;
119
143
  private drainLoop;
120
144
  /** Tell retention where this reader is, when it has moved. */
@@ -127,7 +151,17 @@ export declare class OutboxChangeSource implements ChangeSource {
127
151
  * rather than each other's.
128
152
  */
129
153
  prune(): Promise<number>;
154
+ /**
155
+ * One page of a round: rows of transactions `target` sees and the cursor
156
+ * does not, whole transactions only, xids above `after`.
157
+ *
158
+ * The first page of a round has no target yet and takes its own statement
159
+ * snapshot as one, so the rows and the snapshot that becomes the cursor
160
+ * cannot disagree. Later pages read in newer statement snapshots and keep
161
+ * to the target explicitly.
162
+ */
130
163
  private fetch;
164
+ private page;
131
165
  }
132
166
  /**
133
167
  * Whole transactions of one read as one batch, in commit order.
@@ -1 +1 @@
1
- {"version":3,"file":"outbox-change-source.d.ts","sourceRoot":"","sources":["../../../src/server/change-source/outbox-change-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,IAAI,CAAC;IACX,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO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+B;IACjD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAA8B;IAC9C,sEAAsE;IACtE,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,SAAS,CAAK;gBAEV,IAAI,EAAE,yBAAyB;IAYrC,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B;;;;;;;;;OASG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,OAAO,CAAC,IAAI;YAKE,SAAS;IA2BvB,8DAA8D;YAChD,aAAa;IAS3B;;;;;;OAMG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;YAOhB,KAAK;CA6BtB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,CAS/E;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,gBAAgB,EAAE,CA0BxE"}
1
+ {"version":3,"file":"outbox-change-source.d.ts","sourceRoot":"","sources":["../../../src/server/change-source/outbox-change-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGlE,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,IAAI,CAAC;IACX,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE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