@syncular/client 0.59.0 → 0.60.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 (66) hide show
  1. package/README.md +27 -27
  2. package/dist/apply.d.ts +6 -5
  3. package/dist/apply.js +52 -25
  4. package/dist/authority.js +21 -16
  5. package/dist/blob.d.ts +4 -4
  6. package/dist/bun-database.js +3 -16
  7. package/dist/client.d.ts +57 -66
  8. package/dist/client.js +701 -796
  9. package/dist/devtools.d.ts +2 -2
  10. package/dist/devtools.js +3 -3
  11. package/dist/diagnostics.d.ts +17 -28
  12. package/dist/diagnostics.js +1 -2
  13. package/dist/errors.d.ts +1 -1
  14. package/dist/errors.js +1 -1
  15. package/dist/failed-overlay.js +4 -1
  16. package/dist/http.js +19 -5
  17. package/dist/invalidation.d.ts +3 -4
  18. package/dist/invalidation.js +9 -22
  19. package/dist/native-bridge.d.ts +7 -16
  20. package/dist/native-bridge.js +16 -41
  21. package/dist/node-database.js +16 -25
  22. package/dist/outbox.js +1 -0
  23. package/dist/progress.d.ts +2 -2
  24. package/dist/query-guard.d.ts +15 -6
  25. package/dist/query-guard.js +38 -6
  26. package/dist/reactive-store.js +2 -2
  27. package/dist/remote.js +9 -9
  28. package/dist/schema.d.ts +3 -2
  29. package/dist/schema.js +28 -12
  30. package/dist/state.d.ts +69 -36
  31. package/dist/state.js +178 -89
  32. package/dist/sync-scheduler.js +2 -2
  33. package/dist/transport.d.ts +2 -2
  34. package/dist/window.d.ts +30 -52
  35. package/dist/window.js +33 -77
  36. package/dist/worker-core.js +6 -6
  37. package/dist/worker-host.d.ts +9 -8
  38. package/dist/worker-host.js +23 -14
  39. package/dist/worker-protocol.d.ts +9 -8
  40. package/package.json +3 -3
  41. package/src/apply.ts +87 -33
  42. package/src/authority.ts +31 -17
  43. package/src/blob.ts +4 -3
  44. package/src/bun-database.ts +9 -14
  45. package/src/client.ts +886 -1037
  46. package/src/devtools.ts +5 -5
  47. package/src/diagnostics.ts +17 -37
  48. package/src/errors.ts +1 -1
  49. package/src/failed-overlay.ts +6 -1
  50. package/src/http.ts +22 -9
  51. package/src/invalidation.ts +9 -29
  52. package/src/native-bridge.ts +22 -58
  53. package/src/node-database.ts +26 -27
  54. package/src/outbox.ts +1 -0
  55. package/src/progress.ts +2 -2
  56. package/src/query-guard.ts +45 -8
  57. package/src/reactive-store.ts +2 -2
  58. package/src/remote.ts +12 -16
  59. package/src/schema.ts +48 -13
  60. package/src/state.ts +246 -125
  61. package/src/sync-scheduler.ts +2 -2
  62. package/src/transport.ts +2 -2
  63. package/src/window.ts +55 -134
  64. package/src/worker-core.ts +6 -6
  65. package/src/worker-host.ts +27 -19
  66. package/src/worker-protocol.ts +8 -8
@@ -45,7 +45,7 @@ export function installSyncScheduler(
45
45
  let backgroundReady = false;
46
46
  let backgroundDue = Number.POSITIVE_INFINITY;
47
47
  let cancelBackground: (() => void) | undefined;
48
- // §7.6 backoff for drives that end without a client retry intent.
48
+ // §7.7 backoff for drives that end without a client retry intent.
49
49
  let retryDelayMs = 250;
50
50
 
51
51
  const report = (error: unknown): void => {
@@ -103,7 +103,7 @@ export function installSyncScheduler(
103
103
  .catch((error: unknown) => {
104
104
  if (stopped) return;
105
105
  report(error);
106
- // §7.7: a retryable drive rejection owes another drive. A retryable
106
+ // §7.8: a retryable drive rejection owes another drive. A retryable
107
107
  // round failure already handed this loop its background intent; the
108
108
  // drive deadline did not. An unreachable endpoint waits for the
109
109
  // host's connectivity resume (§1.8).
package/src/transport.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  /**
9
9
  * One combined push+pull round trip: SSP2 request bytes → response bytes.
10
- * `signal` aborts when the `syncUntilIdle` deadline elapses (§7.7); a
10
+ * `signal` aborts when the `syncUntilIdle` deadline elapses (§7.8); a
11
11
  * transport that honors it releases the round instead of holding it open.
12
12
  */
13
13
  export type SyncTransport = (
@@ -45,7 +45,7 @@ export interface SegmentFetchRequest {
45
45
  */
46
46
  readonly byteLength?: number;
47
47
  readonly onProgress?: (bytesReceived: number) => void;
48
- /** Aborts with the round when the `syncUntilIdle` deadline elapses (§7.7). */
48
+ /** Aborts with the round when the `syncUntilIdle` deadline elapses (§7.8). */
49
49
  readonly signal?: AbortSignal;
50
50
  }
51
51
 
package/src/window.ts CHANGED
@@ -1,20 +1,22 @@
1
- export const PENDING_EVICTIONS = '_syncular_window_pending_evict';
1
+ export const PENDING_EVICTIONS = '_syncular_pending_evictions';
2
2
  export const WINDOWS_TABLE = '_syncular_windows';
3
3
  /**
4
- * Windowed subscriptions (SPEC.md §4.8).
4
+ * Windows (SPEC.md §4.8).
5
5
  *
6
6
  * A window is a partial local replica keyed by scope VALUES: the client
7
- * holds rows for a chosen set of units (one scope value each) of a window
8
- * BASE (a table + one scope variable + the fixed remainder of the scope
9
- * map). Windowing is a set-difference on §4 subscriptions — never a
10
- * mutation of one — so it needs zero wire or server changes.
7
+ * holds the units of a chosen set of values of a window BASE (one scope
8
+ * variable plus fixed values). Windowing is a set difference on §4.1 units,
9
+ * never a mutation of one, so it needs no wire or server change.
11
10
  *
12
- * This module owns the registry bookkeeping and the deterministic
13
- * per-unit subscription-id derivation (§4.1 guidance). The eviction that
14
- * fuses with a shrink (E1–E4) lives on the client, which holds the DB
15
- * transaction and the invalidation choke point.
11
+ * This module owns the registry bookkeeping. The eviction that fuses with a
12
+ * shrink (E1–E4) lives on the client, which holds the DB transaction and the
13
+ * invalidation choke point.
16
14
  */
17
- import { canonicalScopeJson, type ScopeMap } from '@syncular/core';
15
+ import {
16
+ canonicalUnitJson,
17
+ type ScopeMap,
18
+ type UnitScopes,
19
+ } from '@syncular/core';
18
20
  import type { ClientDatabase } from './database';
19
21
  import { invalidRequest } from './errors';
20
22
 
@@ -80,173 +82,92 @@ export function last(
80
82
  }
81
83
 
82
84
  /**
83
- * A window base: one table, one variable whose values are the window
84
- * units, and any FIXED scopes every unit shares (other variables pinned
85
- * to a constant set). `params` is host-opaque, carried onto every unit's
86
- * subscription verbatim.
85
+ * A window base (§4.8): the selected scope variable plus the fixed scope
86
+ * values every unit of its family shares. A base names no table: each unit
87
+ * covers every table declaring its variables (§4.1).
87
88
  */
88
89
  export interface WindowBase {
89
- readonly table: string;
90
90
  /** The scope variable whose values are the window units. */
91
91
  readonly variable: string;
92
- /** Scopes shared by every unit (other variables), if any. */
93
- readonly fixedScopes?: Readonly<Record<string, readonly string[]>>;
94
- readonly params?: string;
95
- }
96
-
97
- /** A live unit in the registry: its value and the subscription it drives. */
98
- export interface WindowUnit {
99
- readonly unit: string;
100
- readonly subId: string;
101
- }
102
-
103
- export interface RegisteredWindowUnit extends WindowUnit {
104
- readonly baseKey: string;
92
+ /** One value per other variable, shared by every unit. */
93
+ readonly fixedScopes?: UnitScopes;
105
94
  }
106
95
 
107
- /**
108
- * A stable, server-opaque key for a window base — table + variable +
109
- * canonical fixed scopes. Two `setWindow` calls with the same base
110
- * address the same registry rows.
111
- */
96
+ /** A stable key for a window base: variable + canonical fixed scopes. */
112
97
  export function windowBaseKey(base: WindowBase): string {
113
- const fixed = canonicalScopeJson(base.fixedScopes ?? {});
114
- return `${base.table}\0${base.variable}\0${fixed}`;
115
- }
116
-
117
- /** The full requested scope map for one unit (fixed scopes + the unit). */
118
- export function unitScopes(base: WindowBase, unit: string): ScopeMap {
119
- const scopes: ScopeMap = {};
120
- for (const [variable, values] of Object.entries(base.fixedScopes ?? {})) {
121
- scopes[variable] = [...values];
122
- }
123
- scopes[base.variable] = [unit];
124
- return scopes;
98
+ return `${base.variable}\0${canonicalUnitJson(base.fixedScopes ?? {})}`;
125
99
  }
126
100
 
127
- /**
128
- * Deterministic per-unit subscription id (§4.1 guidance):
129
- * `w:<table>:<sha256(canonical scope map, §11.2)[0..16]>`. Ids are echoed
130
- * not interpreted by the server (§4.1), so the exact hash is pure client
131
- * convention; SHA-256 matches the SPEC's worked example.
132
- */
133
- export async function deriveSubId(
134
- base: WindowBase,
135
- unit: string,
136
- ): Promise<string> {
137
- const canonical = canonicalScopeJson(unitScopes(base, unit));
138
- const digest = await crypto.subtle.digest(
139
- 'SHA-256',
140
- new TextEncoder().encode(canonical),
141
- );
142
- let hex = '';
143
- for (const byte of new Uint8Array(digest)) {
144
- hex += byte.toString(16).padStart(2, '0');
145
- }
146
- return `w:${base.table}:${hex.slice(0, 16)}`;
101
+ /** The unit of one window value: the fixed scopes plus the value. */
102
+ export function windowUnitScopes(base: WindowBase, value: string): UnitScopes {
103
+ return { ...base.fixedScopes, [base.variable]: value };
147
104
  }
148
105
 
149
- /** Live units for a base, ordered by unit value. */
106
+ /** Registry rows for a base, ordered by value: value → unit id. */
150
107
  export function loadWindowUnits(
151
108
  db: ClientDatabase,
152
109
  baseKey: string,
153
- ): WindowUnit[] {
110
+ ): { readonly value: string; readonly unitId: string }[] {
154
111
  return db
155
112
  .query(
156
113
  `SELECT unit,sub_id FROM ${WINDOWS_TABLE} WHERE base=? ORDER BY unit`,
157
114
  [baseKey],
158
115
  )
159
- .map((row) => ({ unit: row.unit as string, subId: row.sub_id as string }));
160
- }
161
-
162
- /** Registry lookup used to emit exact completion changes for a sub id. */
163
- export function getWindowUnitBySubId(
164
- db: ClientDatabase,
165
- subId: string,
166
- ): RegisteredWindowUnit | undefined {
167
- const row = db.query(
168
- `SELECT base, unit, sub_id FROM ${WINDOWS_TABLE}
169
- WHERE sub_id = ? LIMIT 1`,
170
- [subId],
171
- )[0];
172
- return row === undefined
173
- ? undefined
174
- : {
175
- baseKey: row.base as string,
176
- unit: row.unit as string,
177
- subId: row.sub_id as string,
178
- };
179
- }
180
-
181
- export function insertWindowUnit(
182
- db: ClientDatabase,
183
- baseKey: string,
184
- unit: string,
185
- subId: string,
186
- ): void {
187
- db.exec(
188
- `INSERT OR REPLACE INTO ${WINDOWS_TABLE}(base,unit,sub_id)VALUES(?,?,?)`,
189
- [baseKey, unit, subId],
190
- );
191
- }
192
-
193
- export function deleteWindowUnit(
194
- db: ClientDatabase,
195
- baseKey: string,
196
- unit: string,
197
- ): void {
198
- db.exec(`DELETE FROM ${WINDOWS_TABLE} WHERE base=? AND unit=?`, [
199
- baseKey,
200
- unit,
201
- ]);
116
+ .map((row) => ({
117
+ value: row.unit as string,
118
+ unitId: row.sub_id as string,
119
+ }));
202
120
  }
203
121
 
204
- /** Is a single scope value windowed-in for this base? (the oracle, I3) */
205
- export function isUnitLive(
122
+ /** Every window registry row that references a unit (§4.1 references). */
123
+ export function windowRefs(
206
124
  db: ClientDatabase,
207
- baseKey: string,
208
- unit: string,
209
- ): boolean {
210
- return (
211
- db.query(`SELECT 1 FROM ${WINDOWS_TABLE} WHERE base=? AND unit=? LIMIT 1`, [
212
- baseKey,
213
- unit,
214
- ]).length > 0
215
- );
125
+ unitId: string,
126
+ ): { readonly baseKey: string; readonly value: string }[] {
127
+ return db
128
+ .query(`SELECT base,unit FROM ${WINDOWS_TABLE} WHERE sub_id=?`, [unitId])
129
+ .map((row) => ({
130
+ baseKey: row.base as string,
131
+ value: row.unit as string,
132
+ }));
216
133
  }
217
134
 
218
135
  // ---------------------------------------------------------------------------
219
- // Deferred eviction (E1) — units that left the window with pinned rows
136
+ // Deferred eviction (E1): per-table scopes of units that left with rows left
220
137
  // ---------------------------------------------------------------------------
221
138
 
222
139
  export interface PendingEviction {
223
- readonly subId: string;
140
+ readonly unitId: string;
224
141
  readonly table: string;
225
142
  readonly effective: ScopeMap;
226
143
  }
227
144
 
228
145
  export function savePendingEviction(
229
146
  db: ClientDatabase,
230
- subId: string,
231
- table: string,
232
- effective: ScopeMap,
147
+ entry: PendingEviction,
233
148
  ): void {
234
149
  db.exec(
235
- `INSERT OR REPLACE INTO ${PENDING_EVICTIONS}(sub_id, tbl, effective_scopes)
236
- VALUES (?, ?, ?)`,
237
- [subId, table, JSON.stringify(effective)],
150
+ `INSERT OR REPLACE INTO ${PENDING_EVICTIONS}(unit_id,tbl,effective_scopes)VALUES(?,?,?)`,
151
+ [entry.unitId, entry.table, JSON.stringify(entry.effective)],
238
152
  );
239
153
  }
240
154
 
241
- export function deletePendingEviction(db: ClientDatabase, subId: string): void {
242
- db.exec(`DELETE FROM ${PENDING_EVICTIONS} WHERE sub_id = ?`, [subId]);
155
+ export function deletePendingEviction(
156
+ db: ClientDatabase,
157
+ unitId: string,
158
+ table?: string,
159
+ ): void {
160
+ db.exec(
161
+ `DELETE FROM ${PENDING_EVICTIONS} WHERE unit_id=?${table === undefined ? '' : ' AND tbl=?'}`,
162
+ table === undefined ? [unitId] : [unitId, table],
163
+ );
243
164
  }
244
165
 
245
166
  export function loadPendingEvictions(db: ClientDatabase): PendingEviction[] {
246
167
  return db
247
- .query(`SELECT sub_id, tbl, effective_scopes FROM ${PENDING_EVICTIONS}`)
168
+ .query(`SELECT unit_id,tbl,effective_scopes FROM ${PENDING_EVICTIONS}`)
248
169
  .map((row) => ({
249
- subId: row.sub_id as string,
170
+ unitId: row.unit_id as string,
250
171
  table: row.tbl as string,
251
172
  effective: JSON.parse(row.effective_scopes as string) as ScopeMap,
252
173
  }));
@@ -228,7 +228,7 @@ export function startSyncWorkerCore(
228
228
  let autoSyncScheduled = false;
229
229
  let cancelBackground: (() => void) | undefined;
230
230
  let backgroundDue = Number.POSITIVE_INFINITY;
231
- // §7.6 backoff for drives that end without a client retry intent.
231
+ // §7.7 backoff for drives that end without a client retry intent.
232
232
  let retryDelayMs = 250;
233
233
  const scheduleBackground =
234
234
  overrides.scheduleBackground ??
@@ -282,7 +282,7 @@ export function startSyncWorkerCore(
282
282
  t: 'event',
283
283
  event: { kind: 'synced', error: toErrorShape(error) },
284
284
  });
285
- // §7.7: a retryable drive rejection owes another drive. A retryable
285
+ // §7.8: a retryable drive rejection owes another drive. A retryable
286
286
  // round failure already handed this loop its background intent; the
287
287
  // drive deadline did not. An unreachable endpoint waits for the
288
288
  // host's connectivity resume (§1.8).
@@ -545,8 +545,8 @@ export function startSyncWorkerCore(
545
545
  'commitOutcomes',
546
546
  'resolveCommitOutcome',
547
547
  'pendingCommits',
548
- 'subscriptions',
549
- 'subscription',
548
+ 'units',
549
+ 'unit',
550
550
  'connectRealtime',
551
551
  'disconnectRealtime',
552
552
  'setPresence',
@@ -607,7 +607,7 @@ export function startSyncWorkerCore(
607
607
  },
608
608
  resetClientId: () => requireClient().resetClientId(),
609
609
  localRevision: () => requireClient().localRevision,
610
- diagnosticsSnapshot: (request) => {
610
+ diagnosticsSnapshot: () => {
611
611
  const running = requireClient();
612
612
  // The first pull makes the worker a push source: no tab has asked for
613
613
  // diagnostics before it, so no snapshot is built per revision until then.
@@ -615,7 +615,7 @@ export function startSyncWorkerCore(
615
615
  pushingDiagnostics = true;
616
616
  running.onDiagnostics(postDiagnostics);
617
617
  }
618
- return workerDiagnostics(running.diagnosticsSnapshot(request));
618
+ return workerDiagnostics(running.diagnosticsSnapshot());
619
619
  },
620
620
  setHeaders: (next) => {
621
621
  headers = next;
@@ -44,7 +44,6 @@ import type {
44
44
  SecurityLifecycle,
45
45
  SnapshotRead,
46
46
  SnapshotReadRequest,
47
- SubscribeInput,
48
47
  SyncClientConfig,
49
48
  SyncClientLimits,
50
49
  SyncSummary,
@@ -57,7 +56,6 @@ import type { DevtoolsRegistrar } from './devtools';
57
56
  import {
58
57
  ClientDiagnosticsEmitter,
59
58
  type ClientDiagnosticsListener,
60
- type ClientDiagnosticsRequest,
61
59
  type ClientDiagnosticsSnapshot,
62
60
  type RealtimePolicy,
63
61
  withClientDiagnosticsHost,
@@ -110,7 +108,8 @@ import {
110
108
  type PreviousVersionSnapshot,
111
109
  } from './previous-version';
112
110
  import type { ClientSchema } from './schema';
113
- import type { SubscriptionRecord } from './state';
111
+ import type { UnitScopes } from '@syncular/core';
112
+ import type { UnitRecord } from './state';
114
113
  import type { WindowBase } from './window';
115
114
  import {
116
115
  type LocalAuthorityState,
@@ -398,7 +397,7 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
398
397
  clientId: () => this.#clientId,
399
398
  role: () => this.#role,
400
399
  outbox: async () => (await this.statusSnapshot()).outbox,
401
- subscriptions: () => this.subscriptions(),
400
+ units: () => this.units(),
402
401
  conflicts: async () => (await this.conflicts()).length,
403
402
  rejections: async () => (await this.rejections()).length,
404
403
  syncNeeded: async () => (await this.statusSnapshot()).syncNeeded,
@@ -599,12 +598,12 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
599
598
  >;
600
599
  }
601
600
 
602
- subscribe(input: SubscribeInput): Promise<void> {
603
- return this.#call('subscribe', [input]);
601
+ subscribe(scopes: UnitScopes): Promise<string> {
602
+ return this.#call('subscribe', [scopes]);
604
603
  }
605
604
 
606
- subscribeMany(inputs: readonly SubscribeInput[]): Promise<void> {
607
- return this.#call('subscribeMany', [inputs]);
605
+ subscribeMany(units: readonly UnitScopes[]): Promise<string[]> {
606
+ return this.#call('subscribeMany', [units]);
608
607
  }
609
608
 
610
609
  securityLifecycle(): Promise<SecurityLifecycle> {
@@ -742,10 +741,8 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
742
741
  return this.#call('statusSnapshot', []);
743
742
  }
744
743
 
745
- async diagnosticsSnapshot(
746
- request: ClientDiagnosticsRequest = {},
747
- ): Promise<ClientDiagnosticsSnapshot> {
748
- const snapshot = await this.#call('diagnosticsSnapshot', [request]);
744
+ async diagnosticsSnapshot(): Promise<ClientDiagnosticsSnapshot> {
745
+ const snapshot = await this.#call('diagnosticsSnapshot', []);
749
746
  return withClientDiagnosticsHost(snapshot, {
750
747
  ...snapshot.host,
751
748
  kind: 'worker',
@@ -782,12 +779,12 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
782
779
  return this.#call('pendingCommits', []);
783
780
  }
784
781
 
785
- subscriptions(): Promise<SubscriptionRecord[]> {
786
- return this.#call('subscriptions', []);
782
+ units(): Promise<UnitRecord[]> {
783
+ return this.#call('units', []);
787
784
  }
788
785
 
789
- subscription(id: string): Promise<SubscriptionRecord | undefined> {
790
- return this.#call('subscription', [id]);
786
+ unit(id: string): Promise<UnitRecord | undefined> {
787
+ return this.#call('unit', [id]);
791
788
  }
792
789
 
793
790
  connectRealtime(): Promise<void> {
@@ -1001,9 +998,20 @@ async function startWorkerCore(options: {
1001
998
  } as MainToWorkerMessage);
1002
999
  },
1003
1000
  );
1004
- // A config callback is a consumer from the first round.
1005
- if (config.onDiagnostics !== undefined)
1006
- await invoke('diagnosticsSnapshot', []);
1001
+ // A config callback is a consumer from the first round. Under security
1002
+ // preflight the core refuses the snapshot after the pull registered the
1003
+ // worker as a push source, and activateSecurity() emits the first one.
1004
+ if (config.onDiagnostics !== undefined) {
1005
+ await invoke('diagnosticsSnapshot', []).catch((error: unknown) => {
1006
+ if (
1007
+ config.securityPreflight !== true ||
1008
+ !(error instanceof ClientSyncError) ||
1009
+ error.code !== 'client.security_preflight_required'
1010
+ ) {
1011
+ throw error;
1012
+ }
1013
+ });
1014
+ }
1007
1015
  return {
1008
1016
  clientId: initResult.clientId,
1009
1017
  invoke,
@@ -28,7 +28,6 @@ import type {
28
28
  QueryReadSpec,
29
29
  QuerySnapshot,
30
30
  SecurityLifecycle,
31
- SubscribeInput,
32
31
  SyncClientConfig,
33
32
  SyncClientLimits,
34
33
  SyncSummary,
@@ -53,7 +52,8 @@ import type {
53
52
  PreviousVersionSnapshot,
54
53
  } from './previous-version';
55
54
  import type { ClientSchema } from './schema';
56
- import type { SubscriptionRecord } from './state';
55
+ import type { UnitScopes } from '@syncular/core';
56
+ import type { UnitRecord } from './state';
57
57
  import type { WindowBase } from './window';
58
58
 
59
59
  // ---------------------------------------------------------------------------
@@ -183,12 +183,12 @@ export interface WorkerApi extends Omit<
183
183
  securityLifecycle(): SecurityLifecycle;
184
184
  beginSecurityPreflight(): Promise<void>;
185
185
  activateSecurity(options?: WorkerSecurityActivation): Promise<void>;
186
- subscribe(input: SubscribeInput): void;
187
- subscribeMany(inputs: readonly SubscribeInput[]): void;
186
+ subscribe(scopes: UnitScopes): string;
187
+ subscribeMany(units: readonly UnitScopes[]): string[];
188
188
  unsubscribe(id: string): void;
189
- /** §4.8 windowed subscriptions: set the live units for a window base. */
189
+ /** §4.8 windows: set the windowed-in values of a base. */
190
190
  setWindow(base: WindowBase, units: readonly string[]): Promise<void>;
191
- /** §4.8 completeness oracle (I3): the windowed-in units for a base. */
191
+ /** §4.8 completeness oracle: the windowed-in values of a base. */
192
192
  windowState(base: WindowBase): WindowState;
193
193
  mutate(mutations: readonly MutationInput[]): string;
194
194
  /** Partial-update convenience: read-merge-write one full-row upsert. */
@@ -224,8 +224,8 @@ export interface WorkerApi extends Omit<
224
224
  querySnapshot(spec: QueryReadSpec): QuerySnapshot;
225
225
  localRevision(): LocalRevision;
226
226
  pendingCommits(): OutboxCommit[];
227
- subscriptions(): SubscriptionRecord[];
228
- subscription(id: string): SubscriptionRecord | undefined;
227
+ units(): UnitRecord[];
228
+ unit(id: string): UnitRecord | undefined;
229
229
  connectRealtime(): Promise<void>;
230
230
  disconnectRealtime(): void;
231
231
  /** §8.6 presence: publish/clear a scope-keyed presence document. */