@framers/agentos-ext-account-sources 0.9.1 → 0.9.3

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.
@@ -26,8 +26,13 @@ class QuotaLate extends Error {
26
26
  this.retryAt = retryAt;
27
27
  }
28
28
  }
29
- /** Milliseconds after the reservation's clock reading within which an attempt must start its call. */
29
+ /**
30
+ * Milliseconds within which an attempt must start its call, from the clock read once its three budgets hold its weight:
31
+ * their statements run under the project's lock and can take longer than the window.
32
+ */
30
33
  const sendWindowMs = 1000;
34
+ /** The minute budgets' rolling window: a consumed unit leaves it once more than this has passed since its reservation. */
35
+ const minuteMs = 60_000;
31
36
  /** Rows of each table one `compact` call deletes at most. */
32
37
  const compactLimit = 1000;
33
38
  const integer = (n) => Number.isSafeInteger(n) && n >= 0;
@@ -73,7 +78,10 @@ function checkedPolicy(policy) {
73
78
  throw new Error('invalid_source_quota_policy');
74
79
  return Object.freeze(copy);
75
80
  }
76
- /** Combines released meters; this class never reimplements their accounting SQL. */
81
+ /**
82
+ * Combines released meters, which decide every admission and every refund; this class never reimplements their
83
+ * accounting SQL. It reads a minute budget's reservations only to say when a request it refused has room.
84
+ */
77
85
  export class SourceQuota {
78
86
  db;
79
87
  options;
@@ -111,7 +119,7 @@ export class SourceQuota {
111
119
  }
112
120
  meter(tx, prefix, allowance, daily) {
113
121
  return new SqlSpendMeter({ db: tx, tablePrefix: prefix, allowanceFor: () => allowance,
114
- ...(daily ? { periodOf: (now) => String(Math.floor(now / 86_400_000)) } : { windowMs: 60_000 }),
122
+ ...(daily ? { periodOf: (now) => String(Math.floor(now / 86_400_000)) } : { windowMs: minuteMs }),
115
123
  ensureSchema: false, requireShared: true, leaseMs: 120_000, maxAttemptsPerOperation: 1,
116
124
  unknownAfterLease: 'consume', retry: { attempts: 1, baseDelayMs: 0, maxDelayMs: 0, deadlineMs: 1000 } });
117
125
  }
@@ -139,29 +147,36 @@ export class SourceQuota {
139
147
  }
140
148
  const projectId = JSON.stringify([request.projectKey]);
141
149
  const mailboxId = JSON.stringify([request.projectKey, request.mailboxKey]);
150
+ const units = this.policy.weights[request.method];
142
151
  const meters = [
143
- { meter: this.meter(tx, this.t.pm, this.policy.projectMinute, false), accountId: projectId,
144
- reason: 'project_minute', retryAt: now + 60_001 },
145
- { meter: this.meter(tx, this.t.mm, this.policy.mailboxMinute, false), accountId: mailboxId,
146
- reason: 'mailbox_minute', retryAt: now + 60_001 },
147
- { meter: this.meter(tx, this.t.pd, this.policy.projectDay, true), accountId: projectId,
148
- reason: 'project_day', retryAt: dayEnd(now) },
152
+ { meter: this.meter(tx, this.t.pm, this.policy.projectMinute, false), table: this.t.pm,
153
+ allowance: this.policy.projectMinute, accountId: projectId, reason: 'project_minute' },
154
+ { meter: this.meter(tx, this.t.mm, this.policy.mailboxMinute, false), table: this.t.mm,
155
+ allowance: this.policy.mailboxMinute, accountId: mailboxId, reason: 'mailbox_minute' },
156
+ { meter: this.meter(tx, this.t.pd, this.policy.projectDay, true), table: this.t.pd,
157
+ allowance: this.policy.projectDay, accountId: projectId, reason: 'project_day' },
149
158
  ];
150
159
  for (const entry of meters) {
151
160
  const reserved = await entry.meter.reserve({ accountId: entry.accountId,
152
- operationId: request.attemptId, units: this.policy.weights[request.method], now });
161
+ operationId: request.attemptId, units, now });
153
162
  if (reserved.status !== 'reserved') {
154
163
  if (reserved.reason !== 'allowance_exhausted')
155
164
  throw new QuotaDuplicate();
156
165
  // Propagate past the outer transaction: nested adapter calls have no savepoint.
157
- throw new QuotaDeferred(entry.reason, entry.retryAt);
166
+ throw new QuotaDeferred(entry.reason, entry.reason === 'project_day' ? dayEnd(now)
167
+ : await this.minuteRoom(tx, entry.table, entry.accountId, request.attemptId, units, entry.allowance, now));
158
168
  }
159
169
  const settled = await entry.meter.settle({ operationId: request.attemptId, outcome: 'consumed', now });
160
170
  if (settled.status !== 'settled' || settled.state !== 'consumed')
161
171
  throw new Error('source_quota_settle_failed');
162
172
  }
163
- const permit = { token: randomUUID(), sendBy: now + sendWindowMs,
164
- expiresAt: now + sendWindowMs + this.policy.timeoutMs + this.policy.slotGraceMs, timeoutMs: this.policy.timeoutMs };
173
+ // The send window opens once the three budgets hold the weight, at a second reading of the clock: one counted from
174
+ // the first reading would close while their statements were still running on a slow database. The record below
175
+ // and the commit stay inside the window: no reading can follow a commit inside its own transaction, and the start's
176
+ // reading, which closes the window, is the one that catches a process that stalled after the commit.
177
+ const opened = Math.max(now, await this.now(tx));
178
+ const permit = { token: randomUUID(), sendBy: opened + sendWindowMs,
179
+ expiresAt: opened + sendWindowMs + this.policy.timeoutMs + this.policy.slotGraceMs, timeoutMs: this.policy.timeoutMs };
165
180
  await tx.run(`INSERT INTO ${this.t.attempts}(attempt_id,project_key,mailbox_key,token,send_by,expires_at)
166
181
  VALUES($1,$2,$3,$4,$5,$6)`, [request.attemptId, request.projectKey, request.mailboxKey,
167
182
  permit.token, permit.sendBy, permit.expiresAt]);
@@ -169,7 +184,7 @@ export class SourceQuota {
169
184
  });
170
185
  }
171
186
  async begin(request, permit) {
172
- await this.db.transaction(async (tx) => {
187
+ const late = await this.db.transaction(async (tx) => {
173
188
  const project = await this.project(tx, request.projectKey);
174
189
  const now = await this.now(tx);
175
190
  const mailbox = await tx.get(`SELECT retry_at FROM ${this.t.mailboxes}
@@ -181,12 +196,43 @@ export class SourceQuota {
181
196
  WHERE attempt_id=$1 AND project_key=$2 AND mailbox_key=$3 AND token=$4
182
197
  AND started=FALSE AND finished=FALSE AND send_by>=$5 AND expires_at>$5`, [request.attemptId, request.projectKey, request.mailboxKey, permit.token, now]);
183
198
  if (updated.changes === 1)
184
- return;
199
+ return null;
185
200
  // This run's own attempt, still unstarted, missed only the time conditions: its send window closed before the start.
186
201
  const unstarted = await tx.get(`SELECT attempt_id FROM ${this.t.attempts}
187
202
  WHERE attempt_id=$1 AND project_key=$2 AND mailbox_key=$3 AND token=$4 AND started=FALSE AND finished=FALSE`, [request.attemptId, request.projectKey, request.mailboxKey, permit.token]);
188
- throw unstarted ? new QuotaLate(now + sendWindowMs) : new QuotaDuplicate();
203
+ if (!unstarted)
204
+ throw new QuotaDuplicate();
205
+ // Nothing was sent and only this run holds the attempt's token, so the three budgets take its units back here,
206
+ // under the project's lock, through the core meters' own refund of a consumed reservation (`replaced`).
207
+ for (const meter of [this.meter(tx, this.t.pm, this.policy.projectMinute, false),
208
+ this.meter(tx, this.t.mm, this.policy.mailboxMinute, false), this.meter(tx, this.t.pd, this.policy.projectDay, true)]) {
209
+ const refunded = await meter.settle({ operationId: request.attemptId, outcome: 'replaced', now });
210
+ if (refunded.status !== 'settled' || refunded.state !== 'released')
211
+ throw new Error('source_quota_refund_failed');
212
+ }
213
+ return now + sendWindowMs;
189
214
  });
215
+ if (late !== null)
216
+ throw new QuotaLate(late);
217
+ }
218
+ /**
219
+ * When a minute budget that refused `units` has room for them: a minute and a millisecond after the reservation of the
220
+ * consumed units whose leaving the window, the earliest first, frees enough, read from the core meter's reservations
221
+ * without the refused attempt's own. Units still reserved never leave the window by age, so with them in the way, or
222
+ * for more units than the budget holds, it answers a minute and a millisecond from now.
223
+ */
224
+ async minuteRoom(tx, table, accountId, attemptId, units, allowance, now) {
225
+ const held = await tx.all(`SELECT state,reserved_at,units FROM ${table}_reservations WHERE account_id=$1 AND period='window'
226
+ AND operation_id<>$2 AND (state='reserved' OR (state='consumed' AND reserved_at>=$3)) ORDER BY reserved_at`, [accountId, attemptId, now - minuteMs]);
227
+ let left = held.reduce((sum, row) => sum + Number(row.units), 0);
228
+ for (const row of held) {
229
+ if (row.state !== 'consumed')
230
+ continue;
231
+ left -= Number(row.units);
232
+ if (left + units <= allowance)
233
+ return Number(row.reserved_at) + minuteMs + 1;
234
+ }
235
+ return now + minuteMs + 1;
190
236
  }
191
237
  async release(request, permit) {
192
238
  await this.db.transaction(async (tx) => {
@@ -1 +1 @@
1
- {"version":3,"file":"SourceQuota.js","sourceRoot":"","sources":["../../src/sync/SourceQuota.ts"],"names":[],"mappings":"AAA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AAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,OAAO,GAAG,IAAI,CAAC;gBAAE,MAAM,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC;YACvG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK;gBAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,qBAAqB;QAAE,MAAM,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAC9F,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -138,25 +138,33 @@ export interface SourceSyncSweep {
138
138
  }
139
139
  /**
140
140
  * Thrown by `expire` when it fails after removing at least one source. Each removal committed in a transaction of its
141
- * own, so `partial` counts them in `removed`, with the failure itself in `failed`; `cause` holds the failure, whose
142
- * message this error carries.
141
+ * own, so `partial` counts them in `removed` and names their sources in `sourceIds`, in the order they were removed,
142
+ * with the failure itself in `failed`; `cause` holds the failure, whose message this error carries. The removals stand:
143
+ * a host that counts what `expire` removed adds `partial.removed` in its catch, as `AccountSourceSync.maintain` does.
143
144
  */
144
145
  export declare class SourceSyncExpiryError extends Error {
145
146
  readonly partial: {
146
147
  readonly removed: number;
147
148
  readonly failed: number;
149
+ readonly sourceIds: readonly string[];
148
150
  };
149
- constructor(removed: number, cause: unknown);
151
+ /**
152
+ * @param removed - How many sources were removed before the failure.
153
+ * @param cause - The failure.
154
+ * @param sourceIds - The ids of those sources, in the order they were removed; `expire` always gives them.
155
+ */
156
+ constructor(removed: number, cause: unknown, sourceIds?: readonly string[]);
150
157
  }
151
158
  /**
152
159
  * Durable synchronization state for account sources on PostgreSQL. Every change to an owner's content runs under
153
160
  * that owner's fence (`fence`), and a change made with a handle checks its lease, generation and host liveness in
154
161
  * the same transaction. Applying a changed source purges its old copy and every derived result that depends on it
155
- * before the replacement is written. A read that repeats the text of a copy the store holds is never charged again,
156
- * one that changes it is charged, by the hash the store keeps of each message's text, its new and changed messages and
157
- * the text beside them, and with the host's `refresh` binding a read of that very copy keeps it in place. Provider
158
- * reads, embedding and model calls stay outside the store. The constructor runs no DDL: the host's migration runs
159
- * `sourceSyncSchema` and core's `sourceDerivationSchema` first.
162
+ * before the replacement is written; a read that answers gone or a skip withdraws the copy in a commit of its own
163
+ * before purging it, so a purge that fails leaves nothing derived from it deliverable. A read that repeats the text of
164
+ * a copy the store holds is never charged again, one that changes it is charged, by the hash the store keeps of each
165
+ * message's text, its new and changed messages and the text beside them, and with the host's `refresh` binding a read
166
+ * of that very copy keeps it in place. Provider reads, embedding and model calls stay outside the store. The
167
+ * constructor runs no DDL: the host's migration runs `sourceSyncSchema` and core's `sourceDerivationSchema` first.
160
168
  *
161
169
  * @typeParam Prepared - The host's in-memory value for one document, passed through to its `write` binding.
162
170
  */
@@ -301,11 +309,14 @@ export declare class SqlAccountSourceSyncStore<Prepared = unknown> {
301
309
  * copy's and the message before it is the one the copy has there, itself unchanged. A reply adds its separator and
302
310
  * text, a message edited in place adds itself with the separators on both sides of it, a changed header line or
303
311
  * separator adds the text it is in, a message moved after another neighbour adds its separator, and a read that
304
- * only drops messages adds nothing. A copy whose messages keep no text hash, as an earlier release wrote
312
+ * only drops messages adds nothing, since the messages it keeps follow the same neighbours among those kept (a
313
+ * message that becomes the first keeps its header lines but loses its separator, so those lines are added once).
314
+ * A copy whose messages keep no text hash, as an earlier release wrote
305
315
  * it, is weighed by the hash of its whole text: a read that begins with that text, every message of the copy at the
306
316
  * same span, adds what follows it, and any other read adds all of itself. A connector that caps a thread's text and
307
317
  * spends it on the newest messages first cuts the oldest message shorter at each reply near the cap: that message is
308
- * charged again at its new length, with the separator after it, and the rest of the thread is not. When a repeating
318
+ * charged again at its new length, with the lead of the message after it (its separator and any header lines),
319
+ * and the rest of the thread is not. When a repeating
309
320
  * read also repeats the copy's version and content hash, the host's `refresh` binding keeps the copy, with every
310
321
  * result derived from it, and gives it the read's expiry and message windows; otherwise the copy is written again
311
322
  * from a fresh preparation. A skip and every other result purge the old copy, except an `indexing_limit` skip that
@@ -315,6 +326,12 @@ export declare class SqlAccountSourceSyncStore<Prepared = unknown> {
315
326
  * does not begin with the copy's text, so with the allowance spent it removes the thread's copy, and the thread stays
316
327
  * out of the store until a read of it fits the allowance whole.
317
328
  *
329
+ * A `gone` result and a skip the provider answers withdraw the old copy before that, in a transaction of their own
330
+ * (`withdraw`): its expiry moves to the store's clock, so from then on `readCurrent` answers it expired and the fence
331
+ * neither commits nor delivers a result derived from it, even when the purge that follows fails, as when the host's
332
+ * `purge` binding throws. A failing binding rolls the rest of the application back; the withdrawn copy is past its
333
+ * expiry, so the next `expire` or `sweepExpired` removes it, as does a later application of the read.
334
+ *
318
335
  * @param prepared - The host's prepared value for a document result; null for any other result, and for a document
319
336
  * weighed before its preparation.
320
337
  * @returns The disposition and the handle later calls use, whose ticket reflects any purge; `pending` with the same
@@ -326,6 +343,20 @@ export declare class SqlAccountSourceSyncStore<Prepared = unknown> {
326
343
  * ordered spans of a valid read and an intact copy rule out; nothing is charged or written.
327
344
  */
328
345
  applyResult(h: SourceSyncHandle, work: SourceSyncWork, result: SourceSyncReadResult, prepared: Prepared | null): Promise<SourceSyncApplication | null>;
346
+ /** Whether the connection holds a copy of the source within its expiry, read without a lock. */
347
+ private holds;
348
+ /**
349
+ * Withdraws the copy the store holds of a source a read answered `gone` or skipped, in a transaction of its own,
350
+ * before the one that removes it: the copy's expiry, and its dependency's, move to the store's clock. `readCurrent`
351
+ * then answers it expired, so the fence neither commits nor delivers a result derived from it, and `expire` and
352
+ * `sweepExpired` remove it should the removal fail. The handle, the work item and the result are checked as
353
+ * `applyResult` checks them, and a copy already past its expiry is left as it is.
354
+ *
355
+ * @returns True once the copy is withdrawn or none is held within its expiry; null for a stale handle or work item.
356
+ * @throws {SourceSyncFault} `invalid_response` for a result that does not match its work item or a skip reason the
357
+ * store does not know, with nothing withdrawn.
358
+ */
359
+ private withdraw;
329
360
  private summary;
330
361
  /**
331
362
  * Records the cycle's progress, counted from its stored work and the retained documents.
@@ -396,7 +427,8 @@ export declare class SqlAccountSourceSyncStore<Prepared = unknown> {
396
427
  /**
397
428
  * The current state of each of the derivation's retained sources, read in the given transaction for the fence's
398
429
  * commit and delivery checks; not an authorization answer of its own. An owner the host's `active` binding refuses
399
- * has no sources, and a connection with a barrier or pending revalidation reads as disconnected.
430
+ * has no sources, and a connection with a barrier or pending revalidation reads as disconnected. A copy a `gone` read
431
+ * or a skip withdrew reads as expired until it is removed.
400
432
  */
401
433
  readCurrent(tx: StorageAdapter, derivation: SourceDerivation): Promise<readonly SourceDependencyState[]>;
402
434
  /** Removes the host's content and this store's provenance in the affected scope; the fence calls it inside an invalidation. */
@@ -469,7 +501,7 @@ export declare class SqlAccountSourceSyncStore<Prepared = unknown> {
469
501
  * @returns How many sources were removed.
470
502
  * @throws {Error} `invalid_sync_batch` for another limit, and the failure itself when a removal or the results'
471
503
  * expiry fails: once a source was removed, a `SourceSyncExpiryError` with the failure's message, the failure as its
472
- * `cause` and the removals made before it in `partial`.
504
+ * `cause` and the removals made before it in `partial`, counted in `removed` and named in `sourceIds`.
473
505
  */
474
506
  expire(scope: SourceSyncScope, limit?: number): Promise<number>;
475
507
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SqlAccountSourceSyncStore.d.ts","sourceRoot":"","sources":["../../src/sync/SqlAccountSourceSyncStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,cAAc,EA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9H;;;;OAIG;YACW,IAAI;YA2CJ,MAAM;IASpB,+FAA+F;IACzF,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC3D;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;;;;;OAMG;IACG,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IActE;;;;OAIG;IACG,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5D;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAelE;;;;;;OAMG;YACW,YAAY;IAY1B;;;;;;;;;;;;;;OAcG;IACG,YAAY,CAAC,KAAK,SAAM,EAAE,KAAK,GAAE,gBAAgB,GAAG,IAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IAsChG;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,KAAK,EAAE,gBAAgB,EACvC,MAAM,GAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAqBzF"}
@@ -10,15 +10,21 @@ import { createSourceSyncState, transitionSourceSync, sourceSyncDue, openSourceS
10
10
  import { sourceSyncTables } from './schema.js';
11
11
  /**
12
12
  * Thrown by `expire` when it fails after removing at least one source. Each removal committed in a transaction of its
13
- * own, so `partial` counts them in `removed`, with the failure itself in `failed`; `cause` holds the failure, whose
14
- * message this error carries.
13
+ * own, so `partial` counts them in `removed` and names their sources in `sourceIds`, in the order they were removed,
14
+ * with the failure itself in `failed`; `cause` holds the failure, whose message this error carries. The removals stand:
15
+ * a host that counts what `expire` removed adds `partial.removed` in its catch, as `AccountSourceSync.maintain` does.
15
16
  */
16
17
  export class SourceSyncExpiryError extends Error {
17
18
  partial;
18
- constructor(removed, cause) {
19
+ /**
20
+ * @param removed - How many sources were removed before the failure.
21
+ * @param cause - The failure.
22
+ * @param sourceIds - The ids of those sources, in the order they were removed; `expire` always gives them.
23
+ */
24
+ constructor(removed, cause, sourceIds = []) {
19
25
  super(cause instanceof Error ? cause.message : String(cause), { cause });
20
26
  this.name = 'SourceSyncExpiryError';
21
- this.partial = { removed, failed: 1 };
27
+ this.partial = { removed, failed: 1, sourceIds: Object.freeze([...sourceIds]) };
22
28
  }
23
29
  }
24
30
  class StaleSync extends Error {
@@ -61,20 +67,26 @@ const beginsWith = (stored, read, text) => stored.textHash !== undefined && stor
61
67
  * keeps no text hash, as in a copy an earlier release wrote. A read message is unchanged when the copy holds a message
62
68
  * with its id, text hash, cut and length; its lead, the text before it from the previous message's end (the start of
63
69
  * the text for the first), is unchanged when its hash is the one the copy keeps for the same message and the message
64
- * before it is the one the copy has there, itself unchanged, or none for the first. The read adds all its text except
65
- * its unchanged messages and their unchanged leads: a reply adds its separator and text, a message edited in place
66
- * adds itself with the leads on both sides of it, a changed header line or separator adds the lead it is in, a
67
- * message moved after another neighbour adds its lead, and text after the last message is always added. A copy whose
68
- * spans keep no lead hash has every lead charged.
70
+ * before it is the one the copy has there among the messages the read still holds, itself unchanged, or none for
71
+ * the first. The read adds all its text except its unchanged messages and their unchanged leads: a reply adds its
72
+ * separator and text, a message edited in place adds itself with the leads on both sides of it, a changed header
73
+ * line or separator adds the lead it is in, a message moved after another neighbour adds its lead, a read that only
74
+ * drops messages adds nothing (a message that becomes the first loses the separator from its lead, so its header
75
+ * lines are added once), and text after the last message is always added. A copy whose spans keep no lead hash has
76
+ * every lead charged.
69
77
  */
70
78
  const addedByMessage = (stored, read) => {
71
79
  if (!stored.messages.every((message) => typeof message.textHash === 'string'))
72
80
  return null;
73
81
  const held = new Map();
82
+ // A message's neighbour is the held message before it among those the read still holds, so a read that drops a
83
+ // message leaves the one after it with the neighbour it now follows.
84
+ const kept = new Set(read.messages.map((span) => span.messageId));
74
85
  let previous = null;
75
86
  for (const message of stored.messages) {
76
87
  held.set(message.messageId, { span: message, before: previous });
77
- previous = message.messageId;
88
+ if (kept.has(message.messageId))
89
+ previous = message.messageId;
78
90
  }
79
91
  // The start of the text counts as an unchanged neighbour, so the first message's lead goes with it.
80
92
  let added = read.characters;
@@ -107,11 +119,12 @@ const sameCopy = (stored, read) => sameText(stored, read) && stored.dependency.v
107
119
  * Durable synchronization state for account sources on PostgreSQL. Every change to an owner's content runs under
108
120
  * that owner's fence (`fence`), and a change made with a handle checks its lease, generation and host liveness in
109
121
  * the same transaction. Applying a changed source purges its old copy and every derived result that depends on it
110
- * before the replacement is written. A read that repeats the text of a copy the store holds is never charged again,
111
- * one that changes it is charged, by the hash the store keeps of each message's text, its new and changed messages and
112
- * the text beside them, and with the host's `refresh` binding a read of that very copy keeps it in place. Provider
113
- * reads, embedding and model calls stay outside the store. The constructor runs no DDL: the host's migration runs
114
- * `sourceSyncSchema` and core's `sourceDerivationSchema` first.
122
+ * before the replacement is written; a read that answers gone or a skip withdraws the copy in a commit of its own
123
+ * before purging it, so a purge that fails leaves nothing derived from it deliverable. A read that repeats the text of
124
+ * a copy the store holds is never charged again, one that changes it is charged, by the hash the store keeps of each
125
+ * message's text, its new and changed messages and the text beside them, and with the host's `refresh` binding a read
126
+ * of that very copy keeps it in place. Provider reads, embedding and model calls stay outside the store. The
127
+ * constructor runs no DDL: the host's migration runs `sourceSyncSchema` and core's `sourceDerivationSchema` first.
115
128
  *
116
129
  * @typeParam Prepared - The host's in-memory value for one document, passed through to its `write` binding.
117
130
  */
@@ -576,11 +589,14 @@ export class SqlAccountSourceSyncStore {
576
589
  * copy's and the message before it is the one the copy has there, itself unchanged. A reply adds its separator and
577
590
  * text, a message edited in place adds itself with the separators on both sides of it, a changed header line or
578
591
  * separator adds the text it is in, a message moved after another neighbour adds its separator, and a read that
579
- * only drops messages adds nothing. A copy whose messages keep no text hash, as an earlier release wrote
592
+ * only drops messages adds nothing, since the messages it keeps follow the same neighbours among those kept (a
593
+ * message that becomes the first keeps its header lines but loses its separator, so those lines are added once).
594
+ * A copy whose messages keep no text hash, as an earlier release wrote
580
595
  * it, is weighed by the hash of its whole text: a read that begins with that text, every message of the copy at the
581
596
  * same span, adds what follows it, and any other read adds all of itself. A connector that caps a thread's text and
582
597
  * spends it on the newest messages first cuts the oldest message shorter at each reply near the cap: that message is
583
- * charged again at its new length, with the separator after it, and the rest of the thread is not. When a repeating
598
+ * charged again at its new length, with the lead of the message after it (its separator and any header lines),
599
+ * and the rest of the thread is not. When a repeating
584
600
  * read also repeats the copy's version and content hash, the host's `refresh` binding keeps the copy, with every
585
601
  * result derived from it, and gives it the read's expiry and message windows; otherwise the copy is written again
586
602
  * from a fresh preparation. A skip and every other result purge the old copy, except an `indexing_limit` skip that
@@ -590,6 +606,12 @@ export class SqlAccountSourceSyncStore {
590
606
  * does not begin with the copy's text, so with the allowance spent it removes the thread's copy, and the thread stays
591
607
  * out of the store until a read of it fits the allowance whole.
592
608
  *
609
+ * A `gone` result and a skip the provider answers withdraw the old copy before that, in a transaction of their own
610
+ * (`withdraw`): its expiry moves to the store's clock, so from then on `readCurrent` answers it expired and the fence
611
+ * neither commits nor delivers a result derived from it, even when the purge that follows fails, as when the host's
612
+ * `purge` binding throws. A failing binding rolls the rest of the application back; the withdrawn copy is past its
613
+ * expiry, so the next `expire` or `sweepExpired` removes it, as does a later application of the read.
614
+ *
593
615
  * @param prepared - The host's prepared value for a document result; null for any other result, and for a document
594
616
  * weighed before its preparation.
595
617
  * @returns The disposition and the handle later calls use, whose ticket reflects any purge; `pending` with the same
@@ -601,6 +623,12 @@ export class SqlAccountSourceSyncStore {
601
623
  * ordered spans of a valid read and an intact copy rule out; nothing is charged or written.
602
624
  */
603
625
  async applyResult(h, work, result, prepared) {
626
+ // The purge below runs in the transaction that records the result, so a binding that throws rolls the copy's
627
+ // invalidation back with it. The withdrawal commits first and survives that rollback. Only this lease writes the
628
+ // connection's copies, so a copy not held at this read cannot appear before the purge.
629
+ if ((result.kind === 'gone' || result.kind === 'skipped') && await this.holds(h.lease.scope, work.sourceId)
630
+ && await this.withdraw(h, work, result) === null)
631
+ return null;
604
632
  return this.withHandle(h, async (tx, row) => {
605
633
  const s = h.lease.scope;
606
634
  await this.currentWork(tx, s, row.checkpoint, work);
@@ -731,6 +759,42 @@ export class SqlAccountSourceSyncStore {
731
759
  return { handle: { ...h, ticket }, disposition };
732
760
  });
733
761
  }
762
+ /** Whether the connection holds a copy of the source within its expiry, read without a lock. */
763
+ async holds(scope, sourceId) {
764
+ return !!await this.db.get(`SELECT 1 FROM ${this.t.documents} WHERE tenant_id=$1 AND owner_id=$2
765
+ AND connection_id=$3 AND source_id=$4 AND expires_at>$5`, [...params(scope), sourceId, this.now()]);
766
+ }
767
+ /**
768
+ * Withdraws the copy the store holds of a source a read answered `gone` or skipped, in a transaction of its own,
769
+ * before the one that removes it: the copy's expiry, and its dependency's, move to the store's clock. `readCurrent`
770
+ * then answers it expired, so the fence neither commits nor delivers a result derived from it, and `expire` and
771
+ * `sweepExpired` remove it should the removal fail. The handle, the work item and the result are checked as
772
+ * `applyResult` checks them, and a copy already past its expiry is left as it is.
773
+ *
774
+ * @returns True once the copy is withdrawn or none is held within its expiry; null for a stale handle or work item.
775
+ * @throws {SourceSyncFault} `invalid_response` for a result that does not match its work item or a skip reason the
776
+ * store does not know, with nothing withdrawn.
777
+ */
778
+ async withdraw(h, work, result) {
779
+ return this.withHandle(h, async (tx, row) => {
780
+ const s = h.lease.scope;
781
+ await this.currentWork(tx, s, row.checkpoint, work);
782
+ if (result.kind === 'skipped' && !skipReasons.includes(result.reason))
783
+ throw new SourceSyncFault('invalid_response');
784
+ if (result.id !== work.sourceId)
785
+ throw new SourceSyncFault('invalid_response');
786
+ const now = this.now();
787
+ const held = await tx.get(`SELECT document FROM ${this.t.documents}
788
+ WHERE tenant_id=$1 AND owner_id=$2 AND connection_id=$3 AND source_id=$4 AND expires_at>$5`, [...params(s), work.sourceId, now]);
789
+ if (held) {
790
+ const withdrawn = { ...held.document,
791
+ dependency: { ...held.document.dependency, expiresAt: now } };
792
+ await tx.run(`UPDATE ${this.t.documents} SET document=$5::jsonb,expires_at=$6
793
+ WHERE tenant_id=$1 AND owner_id=$2 AND connection_id=$3 AND source_id=$4`, [...params(s), work.sourceId, JSON.stringify(withdrawn), now]);
794
+ }
795
+ return true;
796
+ });
797
+ }
734
798
  async summary(tx, scope, cp) {
735
799
  const rows = await tx.all(`SELECT work FROM ${this.t.work}
736
800
  WHERE tenant_id=$1 AND owner_id=$2 AND connection_id=$3`, params(scope));
@@ -932,7 +996,8 @@ export class SqlAccountSourceSyncStore {
932
996
  /**
933
997
  * The current state of each of the derivation's retained sources, read in the given transaction for the fence's
934
998
  * commit and delivery checks; not an authorization answer of its own. An owner the host's `active` binding refuses
935
- * has no sources, and a connection with a barrier or pending revalidation reads as disconnected.
999
+ * has no sources, and a connection with a barrier or pending revalidation reads as disconnected. A copy a `gone` read
1000
+ * or a skip withdrew reads as expired until it is removed.
936
1001
  */
937
1002
  async readCurrent(tx, derivation) {
938
1003
  if (!await this.options.bindings.active(tx, derivation))
@@ -1198,7 +1263,7 @@ export class SqlAccountSourceSyncStore {
1198
1263
  * @returns How many sources were removed.
1199
1264
  * @throws {Error} `invalid_sync_batch` for another limit, and the failure itself when a removal or the results'
1200
1265
  * expiry fails: once a source was removed, a `SourceSyncExpiryError` with the failure's message, the failure as its
1201
- * `cause` and the removals made before it in `partial`.
1266
+ * `cause` and the removals made before it in `partial`, counted in `removed` and named in `sourceIds`.
1202
1267
  */
1203
1268
  async expire(scope, limit = 100) {
1204
1269
  if (!Number.isInteger(limit) || limit < 1 || limit > 1000)
@@ -1206,18 +1271,18 @@ export class SqlAccountSourceSyncStore {
1206
1271
  const rows = await this.db.all(`SELECT source_id FROM ${this.t.documents}
1207
1272
  WHERE tenant_id=$1 AND owner_id=$2 AND connection_id=$3 AND expires_at <= $4
1208
1273
  ORDER BY expires_at,source_id LIMIT $5`, [...params(scope), this.now(), limit]);
1209
- let removed = 0;
1274
+ const removed = [];
1210
1275
  try {
1211
1276
  for (const row of rows)
1212
1277
  if (await this.expireSource(scope, row.source_id))
1213
- removed++;
1278
+ removed.push(row.source_id);
1214
1279
  await this.fence.expireResults(scope, limit);
1215
1280
  }
1216
1281
  catch (error) {
1217
- // The removals before the failure have committed, so their count goes to the caller with it.
1218
- throw removed > 0 ? new SourceSyncExpiryError(removed, error) : error;
1282
+ // The removals before the failure have committed, so their count and their sources go to the caller with it.
1283
+ throw removed.length > 0 ? new SourceSyncExpiryError(removed.length, error, removed) : error;
1219
1284
  }
1220
- return removed;
1285
+ return removed.length;
1221
1286
  }
1222
1287
  /**
1223
1288
  * Removes one retained source whose expiry has passed, with every result derived from it, under its owner's row