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

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  A person's own accounts as sources. This library defines `AccountSourceConnector` and the `SourceRef` every passage carries, with helpers for line ranges, links, bounded body reads, requests under the shared public-sources limiter and the cache lifetime of a read, the contracts, pure rules, PostgreSQL store and coordinator of a durable, resumable synchronization, weighted request quotas that every worker shares, and the fenced purge and revocation recovery of a connection's grant.
4
4
 
5
- Install `@framers/agentos-ext-account-sources` with its peer `@framers/agentos` 0.13.134 or later. Node.js 20.19 or later is required. The runtime dependencies are `@framers/agentos-ext-public-sources` and `@framers/sql-storage-adapter`.
5
+ Install `@framers/agentos-ext-account-sources` with its peer `@framers/agentos` 0.13.134 or later. Node.js 22 or later is required, as it is for `@framers/agentos`. The runtime dependencies are `@framers/agentos-ext-public-sources` and `@framers/sql-storage-adapter`.
6
6
 
7
7
  ## Connector
8
8
 
@@ -151,7 +151,7 @@ committableSourceCursor(checkpoint, summary); // 'cursor-42'
151
151
 
152
152
  A connector that can page through an account adds the optional `sync` capability, an `AccountSourceSyncProvider`, and becomes a `ResumableAccountSourceConnector`. The four original methods keep their signatures, and an empty selection is not redefined as the whole account. The provider's calls take a `SourceSyncRequest` (scope, generation, cycle id, cutoff, policy and an optional signal) and commit nothing: `begin` answers the anchor a cycle starts from, `scanPage` a page of candidate ids, `historyPage` the ids changed since an anchor with the cursor the page reached, and `readSource` one item as a `document`, `gone`, `skipped` or `retry` result. Cursors and page tokens are opaque strings; no rule does arithmetic on them or orders them.
153
153
 
154
- A `SourceSyncDocument` holds a `SourceRead` with text, its message spans as UTF-16 offsets into that text, JSON metadata, an activity time, a content hash and the `cache` decision `decideSourceCache` answered for the read. A `SourceSyncWork` row holds ids, revisions, attempts and a disposition, never content. A `SourceSyncEvent` carries a fixed state, a count and an optional duration, never a scope or a provider payload.
154
+ A `SourceSyncDocument` holds a `SourceRead` with text, its message spans as UTF-16 offsets into that text, JSON metadata, an activity time, a content hash and the `cache` decision `decideSourceCache` answered for the read. A `SourceSyncWork` row holds ids, revisions, attempts, the failures recorded across its counts of attempts with the counts they are weighed against, and a disposition, never content. A `SourceSyncEvent` carries a fixed state, a count and an optional duration, never a scope or a provider payload.
155
155
 
156
156
  ### Connection state
157
157
 
@@ -206,7 +206,7 @@ await store.control(scope, { type: 'grant_ready', use: { searchAskEnabled: true,
206
206
  const handle = await store.claim(scope, 'scheduled'); // null unless the connection is due and free
207
207
  ```
208
208
 
209
- `SqlAccountSourceSyncStore` keeps each connection's state, policy, open checkpoint, lease and barrier, the cycle's work rows, the provenance of retained sources and the connection's exclusions in the tables `sourceSyncSchema(prefix)` creates: six statements, with a prefix of a lower-case letter and at most 31 lower-case letters, digits or underscores (`agentos_source_sync` unless given). It needs a PostgreSQL adapter with transactions and runs no DDL. Its `fence` is the core `SqlSourceDerivationStore` on the same adapter, over the tables of `sourceDerivationSchema(derivationPrefix)`: every change to an owner's sources runs under that owner's fence, the one that also commits and delivers results derived from them.
209
+ `SqlAccountSourceSyncStore` keeps each connection's state, policy, open checkpoint, lease and barrier, the cycle's work rows, the provenance of retained sources and the connection's exclusions in the tables `sourceSyncSchema(prefix)` creates: eight statements, with a prefix of a lower-case letter and at most 31 lower-case letters, digits or underscores (`agentos_source_sync` unless given). Besides the four tables and the due and expiry indexes, two indexes of the work rows, one by disposition and source id and one of the waiting rows by retry time, let `takeWork` and `pendingRetry` read one row however many items a cycle queued. A database whose migration ran an earlier release's statements has no work indexes: the store is correct there and each take reads more rows, and running the statements again adds them. It needs a PostgreSQL adapter with transactions and runs no DDL. Its `fence` is the core `SqlSourceDerivationStore` on the same adapter, over the tables of `sourceDerivationSchema(derivationPrefix)`: every change to an owner's sources runs under that owner's fence, the one that also commits and delivers results derived from them.
210
210
 
211
211
  The host supplies seven bindings, and may supply an eighth, `refresh`. The store calls each inside its own transaction, on the transaction adapter it passes:
212
212
 
@@ -223,9 +223,9 @@ The host supplies seven bindings, and may supply an eighth, `refresh`. The store
223
223
 
224
224
  Provider reads, embedding and model calls run between store calls, never inside a binding.
225
225
 
226
- A sync holds a lease. `claim(scope, trigger)` answers a handle only when the owner is active, the `active` binding agrees, no barrier or live lease is set and `sourceSyncDue` holds; `renew(handle)` extends the lease by `leaseMs`; `release(handle, event?)` gives it up, records a deferral or a fixed failure when one is given, and keeps the checkpoint and work for the next claim. `openCycle` opens a checkpoint or answers the one already open, `page` records a page and queues its ids in one transaction (the same page sent again right after answers the same checkpoint; any other stale revision answers null), and `takeWork` marks the next due item attempted before the read; an item that reached five attempts without a recorded result is not taken but waits `pollMs` as a `storage_unavailable` retry. Every call made with a handle checks the owner fence, the lease token and expiry, the generation and the `active` binding in the same transaction; once any of them has moved on, `release(handle)` answers false and every other call answers null.
226
+ A sync holds a lease. `claim(scope, trigger)` answers a handle only when the owner is active, the `active` binding agrees, no barrier or live lease is set and `sourceSyncDue` holds; `renew(handle)` extends the lease by `leaseMs`; `release(handle, event?)` gives it up, records a deferral or a fixed failure when one is given, and keeps the checkpoint and work for the next claim. `openCycle` opens a checkpoint, with the cycle's running counts at zero (`tally`, below), or answers the one already open; `page` records a page and queues its ids in one transaction (the same page sent again right after answers the same checkpoint; any other stale revision answers null), and an id the cycle already queued is queued again, keeping its failures while the provider has not answered it since; and `takeWork` marks the next due item attempted before the read: the first pending item by source id, then the one whose wait passed first, so a read that keeps failing never holds back one that has not failed; an item that reached five attempts without a recorded result is not taken but waits `pollMs` as a `storage_unavailable` retry. Every call made with a handle checks the owner fence, the lease token and expiry, the generation and the `active` binding in the same transaction; once any of them has moved on, `release(handle)` answers false and every other call answers null.
227
227
 
228
- `applyResult(handle, work, result, prepared)` keeps a `retry` result unresolved. A `document` result is weighed first: the store ranks this connection's retained sources and the new one by activity time, newest first with ties broken by source id, and keeps those inside `maxRetainedDocuments`, `maxHeldCharacters` and the allowance. A document that does not fit is recorded as skipped with `document_limit`, `held_limit` or `indexing_limit`, and an excluded one with `excluded`. A document that fits replaces the source's previous copy in the same transaction (host write, indexing charge and provenance), after that copy and every derived result that depends on it are removed through the fence, and this connection's other sources the limits no longer admit are removed with it, never another connection's. A read that repeats the text and message spans of a copy the store still holds, within its expiry and window, adds nothing to index: it is charged nothing and is not weighed against the indexing allowance, so neither a reconcile that reads every retained source again nor a change to a source's labels or history spends any of it. Any other read of such a copy is weighed against the indexing allowance and charged by its new and changed messages: the store keeps the hash of each message's text, and a message the copy holds with the same id, text hash, cut and length is free, as is the text before it (its separator and any header lines) when that text is the copy's and the message before it is the one the copy has there, itself unchanged (`leadHash` on each span); a changed header line or separator is charged, and so are the separator after an edited message and the separator of a message that follows another neighbour than it did. A reply is charged its separator and text, a message edited in place is charged with the separators beside it, and a read that only drops messages is charged nothing, since the messages it keeps follow the same neighbours among those kept (a message that becomes the first keeps its header lines but loses its separator, so those lines are charged once). A connector that caps a thread's text and spends it on the newest messages first, as Gmail's does under its `maxThreadCharacters`, cuts the oldest message shorter at each reply near the cap: that message is charged again at its new length, with the lead of the message after it (its separator and any header lines), and the rest of the thread is not. A copy whose messages keep no text hash, as an earlier release wrote it, is weighed by the hash of its whole text instead: a read that begins with that text, every message of the copy at the same span, is charged what follows it, and any other read, like every read of a copy without either hash, is charged in full. When the read also repeats the copy's version and content hash, the `refresh` binding keeps the copy in place, with every result derived from it, and gives it the read's expiry and message windows; otherwise, and for a host without the binding, the copy is written again from a fresh preparation. A `gone` result, a skip and an excluded document remove the source's previous copy, except an `indexing_limit` skip whose previous copy is within its expiry and window, still admitted as it is by the retained limits, and where the new read begins: the read's text starts with the copy's text, by the hash the store keeps of it, and holds every message of it at the same span. That copy, admitted and charged under an earlier read, stays with the shorter of its own and the read's expiry and message windows until a later read of the source finds room in the allowance (a change to it, or a reconcile) or the copy expires; a read that lost or changed one of its messages removes it. A reply that cuts the oldest message of a thread at the cap changes that message, so with the allowance spent it removes the thread's copy, and the thread stays out of the store until a read of it fits the allowance whole. A `gone` result and a skip the provider answers withdraw the previous copy first, in a transaction of their own: its expiry moves to the store's clock, so from then on `readCurrent` answers it expired and the fence neither commits nor delivers anything derived from it, even when the removal that follows fails, as when the host's `purge` binding throws. A withdrawn copy is past its expiry, so the next `expire` or `sweepExpired` removes it, as does the read's retry. A copy past its expiry or window counts as not held, whether or not `expire` has removed it yet. Given `prepared` as null, a document the store has to write answers `pending` with the same handle and records nothing; apply it again with its prepared value. Such a document reaches the `allowance` binding in both calls, so keep that binding to reads. A failing binding rolls the whole application back, apart from such a withdrawal. The answer carries a new handle whenever a removal advanced the owner's fence; later calls use it. `finish` commits the cycle's target cursor once every work item is terminal, counting from the stored work, and `progress` records the counts so far.
228
+ `applyResult(handle, work, result, prepared)` keeps a `retry` result unresolved and counts it in the row's `failures`, across the counts of attempts `takeWork` starts again after a `pollMs` wait. From the tenth failure on, it records the read as skipped with `attempt_limit` in place of the wait once the failures are evidently the read's own. A failure at the provider counts as the read's own once the provider has answered another read of the cycle (applied, gone or skipped for a reason other than an exclusion) in the run of the read's first such failure, from the claim of that run's lease, or in any run after it; a `storage_unavailable` failure, a preparation's or the store's, once another document of the cycle has been prepared and written in that run or after it. During an outage of the provider or of preparation nothing is answered or prepared, so no read is given up until its cycle has been open for `reconcileMs`; from then on a read's next failure, from its tenth, gives it up, so the cycle ends and a reconcile can follow. A document whose cache lifetime has ended by the store's clock when it is weighed, as one admitted with a few seconds of it left and applied again after a longer preparation, is recorded as skipped with `expired`, never refused as malformed: the skip is terminal, so the cycle commits and the next scheduled sync stays, and the source is read again the next time a cycle lists it: a later history change that names it, or a scan that finds it, such as a reconcile's. A `document` result is weighed first: the store ranks this connection's retained sources and the new one by activity time, newest first with ties broken by source id, and keeps those inside `maxRetainedDocuments`, `maxHeldCharacters` and the allowance. A document that does not fit is recorded as skipped with `document_limit`, `held_limit` or `indexing_limit`, and an excluded one with `excluded`. A document that fits replaces the source's previous copy in the same transaction (host write, indexing charge and provenance), after that copy and every derived result that depends on it are removed through the fence, and this connection's other sources the limits no longer admit are removed with it, never another connection's. A read that repeats the text and message spans of a copy the store still holds, within its expiry and window, adds nothing to index: it is charged nothing and is not weighed against the indexing allowance, so neither a reconcile that reads every retained source again nor a change to a source's labels or history spends any of it. Any other read of such a copy is weighed against the indexing allowance and charged by its new and changed messages: the store keeps the hash of each message's text, and a message the copy holds with the same id, text hash, cut and length is free, as is the text before it (its separator and any header lines) when that text is the copy's and the message before it is the one the copy has there, itself unchanged (`leadHash` on each span); a changed header line or separator is charged, and so are the separator after an edited message and the separator of a message that follows another neighbour than it did. A reply is charged its separator and text, a message edited in place is charged with the separators beside it, and a read that only drops messages is charged nothing, since the messages it keeps follow the same neighbours among those kept (a message that becomes the first keeps its header lines but loses its separator, so those lines are charged once). A connector that caps a thread's text and spends it on the newest messages first, as Gmail's does under its `maxThreadCharacters`, cuts the oldest message shorter at each reply near the cap: that message is charged again at its new length, with the lead of the message after it (its separator and any header lines), and the rest of the thread is not. A copy whose messages keep no text hash, as an earlier release wrote it, is weighed by the hash of its whole text instead: a read that begins with that text, every message of the copy at the same span, is charged what follows it, and any other read, like every read of a copy without either hash, is charged in full. When the read also repeats the copy's version and content hash, the `refresh` binding keeps the copy in place, with every result derived from it, and gives it the read's expiry and message windows; otherwise, and for a host without the binding, the copy is written again from a fresh preparation. A `gone` result, a skip and an excluded document remove the source's previous copy, except an `indexing_limit` skip whose previous copy is within its expiry and window, still admitted as it is by the retained limits, and where the new read begins: the read's text starts with the copy's text, by the hash the store keeps of it, and holds every message of it at the same span. That copy, admitted and charged under an earlier read, stays with the shorter of its own and the read's expiry and message windows until a later read of the source finds room in the allowance (a change to it, or a reconcile) or the copy expires; a read that lost or changed one of its messages removes it. A reply that cuts the oldest message of a thread at the cap changes that message, so with the allowance spent it removes the thread's copy, and the thread stays out of the store until a read of it fits the allowance whole. A `gone` result, a skip the provider answers and an `expired` skip withdraw the previous copy first, in a transaction of their own: its expiry moves to the store's clock, so from then on `readCurrent` answers it expired and the fence neither commits nor delivers anything derived from it, even when the removal that follows fails, as when the host's `purge` binding throws. A withdrawn copy is past its expiry, so the next `expire` or `sweepExpired` removes it, as does the read's retry. A read the store gives up withdraws nothing and keeps the previous copy within its own expiry and window: the read saw nothing of the source, so nothing is decided about the copy, and a later read of the source replaces it. `attempt_limit` is the store's own reason, and a result that carries it is refused as `invalid_response`. A copy past its expiry or window counts as not held, whether or not `expire` has removed it yet. Given `prepared` as null, a document the store has to write answers `pending` with the same handle and records nothing; apply it again with its prepared value. Such a document reaches the `allowance` binding in both calls, so keep that binding to reads. A failing binding rolls the whole application back, apart from such a withdrawal. The answer carries a new handle whenever a removal advanced the owner's fence; later calls use it. `finish` commits the cycle's target cursor once every work item is terminal, counting the cycle's work rows in the database. `progress` records the counts so far without reading a work row: the checkpoint keeps the cycle's running counts (`tally`, a `SourceSyncTally`), which each transaction that settles an item or queues one again changes with it, and the retained sources are counted in the database, so a cycle of many reads costs each read a few rows. A checkpoint an earlier release wrote, without the counts, is counted from its work rows once.
229
229
 
230
230
  Controls run with the owner blocked, a tune (below) aside. `control(scope, event, policy?)` applies `connect_started`, `grant_ready`, `pause`, `resume`, `use_changed`, `policy_changed` (with the new policy), `grant_lost` or `disconnect`: it records a content-free barrier and drops the open cycle in one transaction, then completes the barrier and reactivates the owner. Connecting, grant loss and disconnecting remove the connection's sources, their derived results and its exclusions. Pause, resume, a use change and a policy change move retained content to the new generation with its version kept and its expiry never extended, so no result derived before the change can be delivered again; a policy change also removes the sources the new limits leave out and shortens the expiry of the rest to the new window. `exclude(scope, sourceId)` removes one source and keeps a content-free exclusion; `resetExclusions(scope)` clears them. Both raise the generation and keep the committed cursor, and make a reconcile the next cycle: a fresh bounded scan, then history replayed from that cursor, so a change made since it reaches the store even for an item the scan does not list. A control other than disconnecting throws `stale_source_sync` while the `active` binding refuses the owner. A barrier left by a failure blocks claims and reactivation until `recoverControl(scope)` completes it, and a lifecycle worker calls it even for a paused connection. `expire(scope, limit)` removes retained sources whose expiry has passed, also while the connection is paused or the owner's fence is inactive, as for a suspended account, which stays inactive, then the owner's expired derived results; reads refuse an expired source either way. Each source goes in a transaction of its own. When a removal or the results' expiry fails, `expire` throws the failure; once it had removed a source, it throws a `SourceSyncExpiryError` with the failure's message and `cause`, whose `partial` counts the removals made before it in `removed` and names their sources in `sourceIds`, in the order they went. Those removals committed, so a host that counts what `expire` removed adds `partial.removed` in its catch, as `maintain` does. `sweepExpired(limit?, owner?)` does the same across every connection, or one owner's, the earliest expiry first and by the store's own expiry, however far a maintenance walk is from them, and answers `{ removed, failed }`: an owner whose removal fails, as when its host purge keeps failing, is counted and left out of the call's later reads, so a call with up to `limit` such owners never holds back another owner's copies. An owner whose derived results then fail to expire is counted too, once; the call still answers every source it removed, and the other owners' results still expire. `removeOwner(owner, remove?)` removes a stopped owner's rows in one transaction: each of its connections, with its work rows, provenance and exclusions, once every one is disconnected with no barrier, lease, work or retained source, after running the lifecycle's own `remove` in the same transaction; the core fence's owner row and deletion records stay, since they hold no content and a restore replays the deletion from them.
231
231
 
@@ -289,9 +289,9 @@ while (compaction.more) compaction = await quota.compact();
289
289
 
290
290
  `SourceQuota` admits provider requests against weighted budgets that every worker shares through PostgreSQL: a project's rolling minute (`projectMinute`), one mailbox's rolling minute (`mailboxMinute`) and a project's UTC day (`projectDay`). Each budget is a core `SqlSpendMeter` under a table prefix of its own (`<prefix>_pm`, `<prefix>_mm` and `<prefix>_pd`), and at most `projectConcurrency` requests of a project and `mailboxConcurrency` of one mailbox are in flight at once. The quota needs a PostgreSQL adapter with transactions and runs no DDL: the host's migration runs, each with `exec`, the seven scripts `sourceQuotaSchema(prefix)` answers, under a prefix of a lower-case letter and at most 27 lower-case letters, digits or underscores (`agentos_source_quota` unless given). Keys are opaque strings of 1 to 512 characters; a mailbox key stays the same for its mailbox and is never an address. The tables hold keys, counts and times, never content.
291
291
 
292
- `run(request, send, signal?)` decides in one transaction under the project's row lock. An attempt id seen before answers `{ kind: 'duplicate' }`. A recorded provider wait, a full concurrency limit or a budget without room for the method's weight answers `{ kind: 'deferred', reason, retryAt }`, with the wait's own time, the earliest expiry of the slots in the way, for a minute budget the time enough of the units in its window have left it (a minute and a millisecond after their reservations, or 60,001 milliseconds on for a weight larger than the budget), or the next UTC midnight for the day; a refusal by one budget rolls back what the others took. Otherwise the transaction consumes the weight in all three budgets, reads the clock again and records the attempt's slot, and a second transaction starts the call. The call has a second from that second reading to start, so however long the three budgets' statements take, none of it comes out of that second. The slot's record, the commit and the second transaction's wait for a connection and for the project's lock do come out of it: no reading of the clock can follow a commit inside its own transaction, and only the start's reading catches a process that stalled after the commit. An attempt that cannot start within it, after a slow commit, a long wait for the project's lock or a stalled process, answers `{ kind: 'late', retryAt }` and gives its weight back to the three budgets, since nothing was sent: it is retryable with a new attempt id from `retryAt`, a second after the late start was found. Otherwise `run` calls `send` once, outside any transaction, with a signal that aborts after `timeoutMs` or with the caller's signal, then answers `{ kind: 'completed', value }`. Nothing is sent for a duplicate, a deferral or a late start. Units once consumed stay consumed after a failed request, and after a provider wait recorded between the reservation and the call defers the request. A retry is a new `run` with a new attempt id, and pays again. `send` consumes or cancels the response body before it resolves, honors the signal and never retries. The slot frees when `run` finishes, whether it sent or not, or, for a process that dies mid-request, once a second to start, `timeoutMs` and `slotGraceMs` have passed; the attempt id stays refused either way.
292
+ `run(request, send, signal?)` decides in one transaction under the project's row lock. An attempt id seen before answers `{ kind: 'duplicate' }`. A recorded provider wait, a full concurrency limit or a budget without room for the method's weight answers `{ kind: 'deferred', reason, retryAt }`, with the wait's own time, the earliest expiry of the slots in the way, for a minute budget the time enough of the units in its window have left it (a minute and a millisecond after their reservations, or 60,001 milliseconds on for a weight larger than the budget), or the next UTC midnight for the day; a refusal by one budget rolls back what the others took. Otherwise the transaction consumes the weight in all three budgets, reads the clock again and records the attempt's slot, and a second transaction starts the call. The call has a second from that second reading to start, so however long the three budgets' statements take, none of it comes out of that second. The slot's record, the commit and the second transaction's wait for a connection and for the project's lock do come out of it: no reading of the clock can follow a commit inside its own transaction, and only the start's reading catches a process that stalled after the commit. An attempt that cannot start within it, after a slow commit, a long wait for the project's lock or a stalled process, answers `{ kind: 'late', retryAt }` and gives its weight back to the three budgets, since nothing was sent: it is retryable with a new attempt id from `retryAt`, a second after the late start was found. Otherwise `run` calls `send` once, outside any transaction, with a signal that aborts after `timeoutMs` or with the caller's signal, then answers `{ kind: 'completed', value }`. Nothing is sent for a duplicate, a deferral or a late start. Units once consumed stay consumed after a failed request, and after a provider wait recorded between the reservation and the call defers the request. A retry is a new `run` with a new attempt id, and pays again. `send` consumes or cancels the response body before it resolves, honors the signal and never retries. The slot frees when `run` finishes, whether it sent or not, or, for a process that dies mid-request, once a second to start, `timeoutMs` and `slotGraceMs` have passed; the attempt id stays refused either way. A failure to release the slot behind what `send` threw never replaces what it threw, so a refused grant reaches the caller as `grant_rejected` and not as `storage_unavailable`; behind a completed call it is `storage_unavailable`, and the slot frees at its expiry either way.
293
293
 
294
- `run` throws `source_sync_invalid_response` for a key outside those bounds or a method without a weight, `source_sync_cancelled` when the caller's signal aborted before the call or by the time `send` resolves, `source_sync_network` when `send` resolves after its timeout aborted it, and `source_sync_storage_unavailable` when the store cannot answer. Every worker on the same tables runs the same policy: the first one to use a project records its policy there, and a worker with another policy gets `source_sync_storage_unavailable` too. An error that `send` throws reaches the caller unchanged, unless the store then fails to free the slot.
294
+ `run` throws `source_sync_invalid_response` for a key outside those bounds or a method without a weight, `source_sync_cancelled` when the caller's signal aborted before the call or by the time `send` resolves, `source_sync_network` when `send` resolves after its timeout aborted it, and `source_sync_storage_unavailable` when the store cannot answer. Every worker on the same tables runs the same policy: the first one to use a project records its policy there, and a worker with another policy gets `source_sync_storage_unavailable` too. An error that `send` throws reaches the caller unchanged, even when the store then fails to free the slot.
295
295
 
296
296
  `defer(scope, retryAt)` records a provider's wait until `retryAt`, in epoch milliseconds, for one mailbox (`{ projectKey, mailboxKey }`) or the whole project (`{ projectKey }`). A shorter wait never replaces a longer one, and every worker honors it, across restarts. `compact()` deletes attempt records a day after their slots expired, mailbox waits that have passed, the meters' reservations settled more than a day ago and the minute budgets' rows idle for a day, at most 1,000 rows of each table a call; the daily totals stay. It answers what it deleted as `{ attempts, mailboxWaits, reservations, windows, more }`: the rows of each kind, with the three meters' reservations counted together and the two minute budgets' rows together, and `more`, true when a table gave a full 1,000 rows. The coordinator's `maintain` calls it in the first batch of each walk when it is given the quota (`quota`), again while `more` is true, ten calls at most; a host without a coordinator calls it on a schedule, and again while `more` is true. Attempt ids must never repeat: once its record is compacted, an old id is no longer refused.
297
297
 
@@ -328,15 +328,15 @@ do after = (await sync.maintain(after, 100)).next; while (after !== null);
328
328
 
329
329
  `AccountSourceSync` runs a connection's sync on the SQL store and keeps nothing of its own between calls: the checkpoint, the queued reads, the attempt counts and the retry times are in the store, so any coordinator on the same tables, in this process or another, resumes a run that yielded or stopped. `sourceSyncCoordinatorSchema(prefix)` answers one statement, which adds the nullable JSONB column `operation` to the connections table under the prefix given to `sourceSyncSchema`; run it after that schema, on a new database or an existing one. The store never runs it.
330
330
 
331
- The provider factory receives `currentHandle`, which answers the handle the run holds when it is called; the handle changes after each applied result. The factory builds a provider bound to the lease and sends no request. `prepare` turns a document into the host's prepared value, such as its passages and vectors, outside any transaction, and the store commits that value with the document. The run calls it only for a document the store has to write, so a read the store skips is never prepared, and with the `refresh` binding neither is a read of the copy it already holds. `lifecycle.recover(scope)` completes the host's committed purges; `lifecycle.loseGrant(handle, reason)` receives the run's exact handle, compares it atomically before it fences the grant, so a stale run cannot revoke a newer grant, and answers whether it acted. `runBudgetMs` (90,000 unless given, at most 90,000) bounds one run and `operationTimeoutMs` (30,000 unless given, at most 60,000) one provider call or preparation; another value throws `invalid_source_coordinator_policy`. `clock` and `random` (the retry jitter, from 0 to 1) default to `Date.now` and `Math.random`.
331
+ The provider factory receives `currentHandle`, which answers the handle the run holds when it is called; the handle changes after each applied result. The factory builds a provider bound to the lease and sends no request. `prepare` turns a document into the host's prepared value, such as its passages and vectors, outside any transaction, and the store commits that value with the document. The run calls it only for a document the store has to write, so a read the store skips is never prepared, and with the `refresh` binding neither is a read of the copy it already holds. A document whose cache lifetime ends while it is prepared is recorded as an `expired` skip when it is applied again, and the run goes on; it is not a malformed response. `lifecycle.recover(scope)` completes the host's committed purges; `lifecycle.loseGrant(handle, reason)` receives the run's exact handle, compares it atomically before it fences the grant, so a stale run cannot revoke a newer grant, and answers whether it acted. `runBudgetMs` (90,000 unless given, at most 180,000) bounds one run and `operationTimeoutMs` (30,000 unless given, at most 90,000) one provider call or preparation; another value throws `invalid_source_coordinator_policy`. The run budget counts from the start of the run, its setup included, and cuts each call at its end, so a read and its preparation have to fit it together; its ceiling holds one of each at the operation ceiling. A provider whose one call makes several requests in sequence, each under its own deadline, needs their sum: a Gmail read on a fresh connector refreshes the grant, then reads the profile, the labels and the thread, and `runGmailSourceSync` gives each call 90,000 and the run 180,000 unless the host names values. `clock` and `random` (the retry jitter, from 0 to 1) default to `Date.now` and `Math.random`.
332
332
 
333
333
  `run(scope, trigger, signal?)` calls `lifecycle.recover` and the store's `recoverControl` for the scope, then claims the lease; a run that claims nothing answers `idle`. With no open cycle it opens one: `bootstrap` when no cursor is committed, `reconcile` once `reconcileMs` has passed since the last cycle that was not incremental or after a change to the exclusions, otherwise `incremental`. A bootstrap, a reconcile and a recovery call the provider's `begin` for an anchor before their scan. A bootstrap and a recovery replay history from that anchor. A reconcile replays it from the committed cursor: history ids only increase, so that replay also covers the changes made between the cursor and the anchor, and a change to an item the bounded scan does not list still reaches the store. Before its scan, a reconcile asks the provider for the first history page from the committed cursor; when that answers `history_expired`, nothing before the anchor can be replayed, so the reconcile replays from its anchor instead, with one scan and one read pass. An incremental cycle replays history from the committed cursor without a scan. A reconcile is also what keeps an unchanged source: it reads every listed source again, and the store charges nothing for the copy it holds, refreshing it in place with the `refresh` binding, but only while it still holds that copy. Set `reconcileMs` below the cache lifetime the connector's reads carry, by more than one poll and the time a reconcile takes; otherwise each copy expires, and `expire` removes it, before the next reconcile reads it again, and it returns as a new admission, charged again.
334
334
 
335
- The run drains the queued reads before it asks for the next page. Each item is read, unless it is excluded, which records it as skipped. The read goes to `applyResult` before any preparation: the store records a skip, or with the `refresh` binding applies a read of the copy it holds, and answers `pending` for a document it has to write, which the run then prepares and applies again. The run goes on with the handle the application answers. When no read is due, a read waiting for its retry time ends the run as `deferred` until then; otherwise the run records the next page, and once the last history page is recorded and every item is terminal, `finish` commits the cursor and the run answers `completed`. A run yields, keeping its checkpoint and reads for the next claim, after `maxChangedPerLease` reads, after `maxHistoryPagesPerLease` history pages, when `runBudgetMs` has passed or when `signal` aborts; a signal aborted before the run starts answers `yielded` at once. It never waits out a retry.
335
+ The run drains the queued reads before it asks for the next page. Each item is read, unless it is excluded, which records it as skipped. The read goes to `applyResult` before any preparation: the store records a skip, or with the `refresh` binding applies a read of the copy it holds, and answers `pending` for a document it has to write, which the run then prepares and applies again. The run goes on with the handle the application answers. A read that fails with a retriable failure is recorded with its wait. After a `network` or `provider_unavailable` failure with no retry time from the provider, which may be the read's own, the run goes on to the next due read, one that has not failed before one whose wait has passed, so a source that keeps failing holds back none queued with it; a second failure in a row ends the run as `deferred`, so an outage that starts during a run fails at most two reads after the run's last answer. A `rate_limited` failure and one that carries the provider's retry time, as Gmail's do for its waits on the mailbox and the project, end the run until that time, so nothing more is sent before it; a `storage_unavailable` failure, from preparation or storage on this side, ends it until the read's wait, unless the store gave the read up. When no read is due, the earliest wait among the reads ends the run as `deferred` until then; otherwise the run records the next page, and once the last history page is recorded and every item is terminal, `finish` commits the cursor and the run answers `completed`. A run yields, keeping its checkpoint and reads for the next claim, after `maxChangedPerLease` reads, after `maxHistoryPagesPerLease` history pages, when `runBudgetMs` has passed or when `signal` aborts; a signal aborted before the run starts answers `yielded` at once. It never waits out a retry.
336
336
 
337
337
  Before each provider call and each preparation the run renews its lease, and the call gets a signal that aborts after `operationTimeoutMs`, at the end of the run budget or a second before the lease expires, whichever comes first. A provider call cut off by that signal counts as a `network` failure and a preparation as `storage_unavailable`; one cut off by the caller's signal yields. The store refuses a result that arrives after the lease, the generation or the owner's fence has moved on, as after a disconnect, and the run then answers `stale`. A failed request is never an empty page, and a bounded scan never proves that an item it did not list is gone.
338
338
 
339
- Attempts are counted before each call, so a process that dies during a call has used that attempt. The anchor read and each page are counted in the connection's `operation` column, under a SHA-256 digest that names the operation, so a new generation, cycle, revision or phase starts a new count; the column holds no page token, cursor or provider id. A reconcile's look at the committed cursor's history shares the count of its anchor read, and a recovery's anchor read continues the count of the history page that answered `history_expired`, so the one column never alternates between two operations, and while a call keeps failing the count reaches five attempts and the `pollMs` wait. Each read is counted in its work row. A `network`, `rate_limited`, `provider_unavailable` or `storage_unavailable` failure records a wait of `sourceRetryAt`: one second doubled for each earlier attempt, with up to as much again as jitter and at most 60 seconds, or the provider's own retry time when that is later. The fifth attempt's wait is at least `pollMs`, and the attempt after it starts a new count of five; five attempts that recorded nothing also wait `pollMs`. The connection's next sync is then that wait, which neither a restart nor a manual request shortens.
339
+ Attempts are counted before each call, so a process that dies during a call has used that attempt. The anchor read and each page are counted in the connection's `operation` column, under a SHA-256 digest that names the operation, so a new generation, cycle, revision or phase starts a new count; the column holds no page token, cursor or provider id. A reconcile's look at the committed cursor's history shares the count of its anchor read, and a recovery's anchor read continues the count of the history page that answered `history_expired`, so the one column never alternates between two operations, and while a call keeps failing the count reaches five attempts and the `pollMs` wait. Each read is counted in its work row. A `network`, `rate_limited`, `provider_unavailable` or `storage_unavailable` failure records a wait of `sourceRetryAt`: one second doubled for each earlier attempt, with up to as much again as jitter and at most 60 seconds, or the provider's own retry time when that is later. The fifth attempt's wait is at least `pollMs`, and the attempt after it starts a new count of five; five attempts that recorded nothing also wait `pollMs`. A read's failures are also counted across its counts, in its work row's `failures`. From its tenth, the fifth of the count after the wait, the store records the read as skipped with `attempt_limit` in place of a wait once the failures are evidently its own, or once its cycle has been open for `reconcileMs` (see `applyResult` in [The SQL store](#the-sql-store)); until then a read that keeps failing waits, as every read does in an outage, and its cycle holds the cursor. Past a given-up read the cycle commits its cursor, the copy the store holds of the source stays until a later read replaces it or it expires, and the source is read again when a change lists it in history or a reconcile's scan lists it; a page of the same cycle that lists it again queues it with its failures, so its next failure gives it up again. The time a run defers to is the connection's next sync, which neither a restart nor a manual request shortens.
340
340
 
341
341
  A `grant_rejected` or `insufficient_scope` failure goes to `lifecycle.loseGrant` with the run's handle, and the run answers `reconnect`, or `stale` when `loseGrant` answers false. A `domain_policy` or `invalid_response` failure releases the lease with that failure, which clears the next scheduled sync until a manual request or another control sets one, and the run answers `failed`. An unknown exception from the provider becomes `invalid_response`, and one from preparation or storage `storage_unavailable`; no exception text reaches a result or an event. Expired history (`history_expired`) on a history page opens a `recovery` cycle with a fresh anchor and a new bounded scan; a second expiry in the same run defers the sync as `provider_unavailable` for `pollMs`. Retained items the scan does not list stay until they expire.
342
342
 
@@ -391,7 +391,7 @@ The host wires it in four places. The store's `active` binding answers true only
391
391
 
392
392
  `status(scope)` answers `{ localPending, revocation }`, with `revocation` one of `not_needed`, `pending`, `confirmed` and `permission_removal_required`; the local purge completes whatever the revocation's outcome. A provider can revoke a whole grant rather than one connection's, so `canConnect` stays false while a revocation of the owner's is pending, or expired or unreadable and not yet acknowledged. `acknowledgeRemoval(scope)` records the account owner's statement that the permission was removed at the provider, after which a new grant may begin; it is an attestation, never a confirmation. `compact()` removes, a day after their deadline, terminal rows that nothing refers to. `removeOwner(owner)` removes a deleted owner's rows in one transaction once nothing about them is pending: its connections and their work, provenance and exclusions in the store, and its stop intents, the queue rows they and its exchanges refer to, its grant leases and its exchanges here. It answers `pending`, changing nothing, while the deletion's purge or a revocation of its grants is pending and until a day after its last exchange ended, since a grant can still return for that exchange and must find its record to be queued for revocation; it answers `not_deleted` for an owner whose deletion is not recorded, and `removed` again for an owner already removed. The block marker stays, recording the deletion, so `permits` and `canConnect` stay false and the owner is refused for good, even while the host's account row still reads active; the core fence's owner row and deletion records stay too. `removeDeletedOwners(limit?)` runs it for at most `limit` deleted owners a call, those with rows left to remove and nothing pending, for a host whose own records of a deleted account are gone. The coordinator's `maintain` runs it and `compact` in the first batch of each walk when this service is its lifecycle; a host without a coordinator runs them on a schedule beside `revokeBatch`. An owner already removed is not taken again.
393
393
 
394
- `withGrant(handle, work, signal?)` runs one grant operation under a durable 30-second grant lease, without holding a transaction over the network; another worker gets `rate_limited` until the lease expires, and the lease is never renewed. `work` receives a `SealedTokenStore` and a signal that aborts after 15 seconds. Every load and save through that store, and the final return, recheck the sync handle and the lease, so after a disconnect or once the lease has expired a held token can be neither saved nor returned (`grant_rejected`).
394
+ `withGrant(handle, work, signal?)` runs one grant operation under a durable 30-second grant lease, without holding a transaction over the network; another worker gets `rate_limited` until the lease expires, and the lease is never renewed. `work` receives a `SealedTokenStore` and a signal that aborts after 15 seconds. Every load and save through that store, and the final return, recheck the sync handle and the lease, so after a disconnect or once the lease has expired a held token can be neither saved nor returned (`grant_rejected`). A failure to delete the lease behind what `work` threw never replaces what it threw, so a refused grant reaches the coordinator as `grant_rejected`, which fences it; behind a result it is `storage_unavailable`, and the lease expires on its own either way.
395
395
 
396
396
  ```ts
397
397
  // The callback's transaction consumes the authenticated start and records the exchange, or rolls back.
@@ -69,9 +69,18 @@ export interface AccountSourceSyncOptions<Prepared> {
69
69
  readonly random?: () => number;
70
70
  /** Receives content-free events; a sink that throws is ignored. */
71
71
  readonly events?: SourceSyncEventSink;
72
- /** How long one run may work before it yields, from 1 to 90,000 milliseconds; 90,000 unless given. */
72
+ /**
73
+ * How long one run may work before it yields, from 1 to 180,000 milliseconds; 90,000 unless given. It counts from
74
+ * the start of the run, its setup included, and each call is cut at its end, so a read and its preparation have to
75
+ * fit it together: the ceiling holds one of each at the ceiling of `operationTimeoutMs`.
76
+ */
73
77
  readonly runBudgetMs?: number;
74
- /** The longest one provider call or preparation may take, from 1 to 60,000 milliseconds; 30,000 unless given. */
78
+ /**
79
+ * The longest one provider call or preparation may take, from 1 to 90,000 milliseconds; 30,000 unless given. A
80
+ * provider whose one call makes several requests in sequence, each under its own deadline, needs their sum: a Gmail
81
+ * read on a fresh connector refreshes the grant and reads the profile, the labels and the thread, and
82
+ * `runGmailSourceSync` gives it 90,000, and the run 180,000, unless the host names values.
83
+ */
75
84
  readonly operationTimeoutMs?: number;
76
85
  }
77
86
  /**
@@ -129,8 +138,8 @@ export declare class AccountSourceSync<Prepared = unknown> {
129
138
  private readonly operationTimeout;
130
139
  /**
131
140
  * @param options - The store, provider factory, preparation, lifecycle binding and optional settings.
132
- * @throws {Error} `invalid_source_coordinator_policy` unless `runBudgetMs` is an integer from 1 to 90,000 and
133
- * `operationTimeoutMs` one from 1 to 60,000.
141
+ * @throws {Error} `invalid_source_coordinator_policy` unless `runBudgetMs` is an integer from 1 to 180,000 and
142
+ * `operationTimeoutMs` one from 1 to 90,000.
134
143
  */
135
144
  constructor(options: AccountSourceSyncOptions<Prepared>);
136
145
  private now;
@@ -142,8 +151,14 @@ export declare class AccountSourceSync<Prepared = unknown> {
142
151
  * the lease, opens a cycle when none is open (`bootstrap` without a cursor, `reconcile` once `reconcileMs` has
143
152
  * passed since the last non-incremental cycle or when none is recorded, as after a change to the exclusions,
144
153
  * otherwise `incremental`), drains the queued reads before asking for the next page, and commits the cursor once
145
- * every item is terminal. It yields with the checkpoint kept after the policy's changed-item or history-page
146
- * budget, the run budget or an aborted signal, and never waits out a retry.
154
+ * every item is terminal. A read that fails with a retriable failure is recorded with its wait, which the store
155
+ * replaces with an `attempt_limit` skip from the tenth failure on once the failures are evidently the read's own.
156
+ * After a `network` or `provider_unavailable` failure with no wait from the provider the run goes on to the next due
157
+ * read, one that has not failed before one whose wait has passed, unless the read before it failed too, which ends
158
+ * the run as `deferred`; a `rate_limited` failure or a provider's wait defers the run until that time, a
159
+ * `storage_unavailable` failure the store did not give up until the read's wait, and with no read due the run defers
160
+ * on the earliest wait. It yields with the checkpoint kept after the policy's changed-item or history-page budget,
161
+ * the run budget or an aborted signal, and never waits out a retry.
147
162
  *
148
163
  * @param scope - The connection.
149
164
  * @param trigger - A scheduled poll or a person's request.
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSourceSync.d.ts","sourceRoot":"","sources":["../../src/sync/AccountSourceSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,yBAAyB,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAChF,kBAAkB,EACF,qBAAqB,EAAmB,mBAAmB,EAC5E,MAAM,YAAY,CAAC;AACpB,OAAO,EACkB,KAAK,yBAAyB,EAAE,KAAK,gBAAgB,EAC7E,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvG;;;;;OAKG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;;OAKG;IACH,mBAAmB,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD;AACD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,QAAQ;IAChD,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,gBAAgB,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACjG;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAA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AAG,OAAO;IAUnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C;;;;OAIG;gBAC0B,OAAO,EAAE,wBAAwB,CAAC,QAAQ,CAAC;IASxE,OAAO,CAAC,GAAG;IAKX,OAAO,CAAC,IAAI;YAKE,MAAM;IAIpB,OAAO,CAAC,EAAE;IAMV;;;;;;;;;;;;;;;;;;OAkBG;IACG,GAAG,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA4OjH;;;;;;;;;;;;;;;;;OAiBG;IACG,QAAQ,CAAC,KAAK,GAAE,eAAe,GAAG,IAAW,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CA4CxG"}
@@ -28,6 +28,10 @@ const retriable = (fault) => retryReasons.includes(fault.code);
28
28
  const digest = (parts) => createHash('sha256').update(JSON.stringify(parts)).digest('hex');
29
29
  /** Quota compactions one maintenance walk runs at most, each deleting up to 1,000 rows of every quota table. */
30
30
  const walkCompactions = 10;
31
+ /** The longest `operationTimeoutMs`: one provider call or preparation. */
32
+ const operationCeiling = 90_000;
33
+ /** The longest `runBudgetMs`: one read and its preparation, each at the operation ceiling. */
34
+ const runBudgetCeiling = 2 * operationCeiling;
31
35
  /**
32
36
  * One lease at a time; all durable state and authorization remain in the SQL store.
33
37
  *
@@ -45,8 +49,8 @@ export class AccountSourceSync {
45
49
  operationTimeout;
46
50
  /**
47
51
  * @param options - The store, provider factory, preparation, lifecycle binding and optional settings.
48
- * @throws {Error} `invalid_source_coordinator_policy` unless `runBudgetMs` is an integer from 1 to 90,000 and
49
- * `operationTimeoutMs` one from 1 to 60,000.
52
+ * @throws {Error} `invalid_source_coordinator_policy` unless `runBudgetMs` is an integer from 1 to 180,000 and
53
+ * `operationTimeoutMs` one from 1 to 90,000.
50
54
  */
51
55
  constructor(options) {
52
56
  this.options = options;
@@ -55,8 +59,9 @@ export class AccountSourceSync {
55
59
  this.runBudget = options.runBudgetMs ?? 90_000;
56
60
  this.operationTimeout = options.operationTimeoutMs ?? 30_000;
57
61
  if (![this.runBudget, this.operationTimeout].every((n) => Number.isSafeInteger(n) && n >= 1)
58
- || this.runBudget > 90_000 || this.operationTimeout > 60_000)
62
+ || this.runBudget > runBudgetCeiling || this.operationTimeout > operationCeiling) {
59
63
  throw new Error('invalid_source_coordinator_policy');
64
+ }
60
65
  }
61
66
  now() {
62
67
  const now = this.clock();
@@ -91,8 +96,14 @@ export class AccountSourceSync {
91
96
  * the lease, opens a cycle when none is open (`bootstrap` without a cursor, `reconcile` once `reconcileMs` has
92
97
  * passed since the last non-incremental cycle or when none is recorded, as after a change to the exclusions,
93
98
  * otherwise `incremental`), drains the queued reads before asking for the next page, and commits the cursor once
94
- * every item is terminal. It yields with the checkpoint kept after the policy's changed-item or history-page
95
- * budget, the run budget or an aborted signal, and never waits out a retry.
99
+ * every item is terminal. A read that fails with a retriable failure is recorded with its wait, which the store
100
+ * replaces with an `attempt_limit` skip from the tenth failure on once the failures are evidently the read's own.
101
+ * After a `network` or `provider_unavailable` failure with no wait from the provider the run goes on to the next due
102
+ * read, one that has not failed before one whose wait has passed, unless the read before it failed too, which ends
103
+ * the run as `deferred`; a `rate_limited` failure or a provider's wait defers the run until that time, a
104
+ * `storage_unavailable` failure the store did not give up until the read's wait, and with no read due the run defers
105
+ * on the earliest wait. It yields with the checkpoint kept after the policy's changed-item or history-page budget,
106
+ * the run budget or an aborted signal, and never waits out a retry.
96
107
  *
97
108
  * @param scope - The connection.
98
109
  * @param trigger - A scheduled poll or a person's request.
@@ -182,13 +193,29 @@ export class AccountSourceSync {
182
193
  throw new SyncDeferred(error.code, retryAt);
183
194
  }
184
195
  };
196
+ // A failed read is recorded with its wait, and the store gives it up (`attempt_limit`) from its tenth failure on
197
+ // once the failures are evidently its own. After a failure that may be the read's own, `network` or
198
+ // `provider_unavailable` with no wait from the provider, the run goes on to the next due read, so one source that
199
+ // keeps failing holds back none queued with it, but a second failure in a row ends the run, so an outage that
200
+ // starts during a run fails no more than two reads after the run's last answer. A `rate_limited` failure or a
201
+ // provider's wait, for the mailbox or the whole project, ends the run until that time, and a failure on this side,
202
+ // a preparation or the store, until the read's wait, unless the store gave the read up.
203
+ let failedInRow = 0;
185
204
  const deferRead = async (work, fault) => {
186
205
  const retryAt = this.at(fault, work.attempts, snapshot.policy.pollMs);
187
- const result = await this.stored(() => this.store.applyResult(needHandle(), work, { kind: 'retry', id: work.sourceId, reason: fault.code, retryAt }, null));
188
- if (!result)
206
+ const applied = await this.stored(() => this.store.applyResult(needHandle(), work, { kind: 'retry', id: work.sourceId, reason: fault.code, retryAt }, null));
207
+ if (!applied)
189
208
  throw new SyncStale();
190
- handle = result.handle;
191
- throw new SyncDeferred(fault.code, retryAt);
209
+ handle = applied.handle;
210
+ failedInRow++;
211
+ const kept = applied.disposition.kind === 'retry';
212
+ if (fault.code === 'rate_limited' || fault.retryAt !== null) {
213
+ throw new SyncDeferred(fault.code, fault.retryAt ?? retryAt);
214
+ }
215
+ if (kept && fault.code === 'storage_unavailable')
216
+ throw new SyncDeferred(fault.code, retryAt);
217
+ if (failedInRow >= 2)
218
+ throw new SyncDeferred(fault.code, kept ? retryAt : this.now() + 1);
192
219
  };
193
220
  try {
194
221
  await this.stored(() => this.options.lifecycle.recover(scope));
@@ -259,12 +286,15 @@ export class AccountSourceSync {
259
286
  const work = await this.stored(() => this.store.takeWork(needHandle()));
260
287
  if (work) {
261
288
  changed++;
289
+ // Whether the provider was asked: an excluded item is recorded without a read, and its skip answers nothing.
290
+ let asked = false;
262
291
  try {
263
292
  let result;
264
293
  if (await this.stored(() => this.store.isExcluded(scope, work.sourceId))) {
265
294
  result = { kind: 'skipped', id: work.sourceId, reason: 'excluded' };
266
295
  }
267
296
  else {
297
+ asked = true;
268
298
  const cp = checkpoint;
269
299
  result = await external((child) => source.readSource(context(cp.cycleId, cp.cutoff, child), work.sourceId), 'invalid_response');
270
300
  }
@@ -295,11 +325,13 @@ export class AccountSourceSync {
295
325
  throw new SourceSyncFault('invalid_response');
296
326
  handle = applied.handle;
297
327
  }
328
+ if (asked)
329
+ failedInRow = 0;
298
330
  }
299
331
  catch (error) {
300
- if (error instanceof SourceSyncFault && retriable(error))
301
- await deferRead(work, error);
302
- throw error;
332
+ if (!(error instanceof SourceSyncFault) || !retriable(error))
333
+ throw error;
334
+ await deferRead(work, error);
303
335
  }
304
336
  const progress = await this.stored(() => this.store.progress(needHandle()));
305
337
  if (!progress)
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSourceSync.js","sourceRoot":"","sources":["../../src/sync/AccountSourceSync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMrD,OAAO,EACL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAiGnE,MAAM,SAAU,SAAQ,KAAK;IAAG,gBAAgB,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAAE;AAC/E,MAAM,SAAU,SAAQ,KAAK;IAAG,gBAAgB,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAAE;AAC/E,MAAM,YAAa,SAAQ,KAAK;IACT;IAAwC;IAA7D,YAAqB,MAA6B,EAAW,OAAe;QAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAAzF,WAAM,GAAN,MAAM,CAAuB;QAAW,YAAO,GAAP,OAAO,CAAQ;IAAmC,CAAC;CACjH;AACD,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AAM,EAAE,CAAC;gBAAC,CAAC;YACrE,CAAC;YACD,IAAI,SAAS,CAAC,mBAAmB,EAAE,CAAC;gBAClC,IAAI,CAAC;oBAAC,aAAa,IAAI,MAAM,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC;oBAAC,MAAM,EAAE,CAAC;gBAAC,CAAC;YAC1F,CAAC;QACH,CAAC;QACD,IAAI,OAAO,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa;YACxE,IAAI,EAAE,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,CAAC;CACF"}
@@ -126,7 +126,8 @@ export declare class SourceQuota {
126
126
  private release;
127
127
  /**
128
128
  * Consume weighted capacity and call the transport once. No inline HTTP retries: a retry, after a deferral or a
129
- * `late` answer among others, is a new `run` with a new attempt id.
129
+ * `late` answer among others, is a new `run` with a new attempt id. A failure to release the attempt's slot behind
130
+ * what `send` threw never replaces it; behind a completed call it is `storage_unavailable`.
130
131
  */
131
132
  run<T>(request: SourceQuotaRequest, send: (signal: AbortSignal) => Promise<T>, parent?: AbortSignal): Promise<SourceQuotaResult<T>>;
132
133
  /** A longer provider wait survives restarts, generation changes and shorter updates. */
@@ -1 +1 @@
1
- {"version":3,"file":"SourceQuota.d.ts","sourceRoot":"","sources":["../../src/sync/SourceQuota.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,G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;;;;OAIG;IACG,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACjF,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IA0CtD,wFAAwF;IAClF,KAAK,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBjH;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAiBhD;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,SAAgB,GAAG,MAAM,CAkBrH"}
@@ -243,7 +243,8 @@ export class SourceQuota {
243
243
  }
244
244
  /**
245
245
  * Consume weighted capacity and call the transport once. No inline HTTP retries: a retry, after a deferral or a
246
- * `late` answer among others, is a new `run` with a new attempt id.
246
+ * `late` answer among others, is a new `run` with a new attempt id. A failure to release the attempt's slot behind
247
+ * what `send` threw never replaces it; behind a completed call it is `storage_unavailable`.
247
248
  */
248
249
  async run(request, send, parent) {
249
250
  if (parent?.aborted)
@@ -266,6 +267,7 @@ export class SourceQuota {
266
267
  parent?.addEventListener('abort', abort, { once: true });
267
268
  let timer;
268
269
  let began = false;
270
+ let failed = false;
269
271
  try {
270
272
  try {
271
273
  await this.begin(request, permit);
@@ -289,16 +291,23 @@ export class SourceQuota {
289
291
  throw new SourceSyncFault(parent?.aborted ? 'cancelled' : 'network');
290
292
  return { kind: 'completed', value };
291
293
  }
294
+ catch (error) {
295
+ failed = true;
296
+ throw error;
297
+ }
292
298
  finally {
293
299
  if (timer !== undefined)
294
300
  clearTimeout(timer);
295
301
  parent?.removeEventListener('abort', abort);
296
- // Request units remain consumed even if begin, transport, parsing or cleanup fails.
302
+ // Request units remain consumed even if begin, transport, parsing or cleanup fails. A release that fails behind
303
+ // what `send` threw never replaces it: a refused grant has to reach the coordinator as `grant_rejected`, which
304
+ // fences the grant, not as `storage_unavailable`, which only schedules a retry. Behind a completed call it is
305
+ // still a storage failure, and the slot frees at its expiry either way.
297
306
  try {
298
307
  await this.release(request, permit);
299
308
  }
300
309
  catch {
301
- if (began)
310
+ if (began && !failed)
302
311
  throw new SourceSyncFault('storage_unavailable');
303
312
  }
304
313
  }