@framers/agentos-ext-account-sources 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -2
- package/dist/cachePolicy.d.ts.map +1 -1
- package/dist/cachePolicy.js +37 -3
- package/dist/cachePolicy.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/state.d.ts +24 -0
- package/dist/sync/state.d.ts.map +1 -0
- package/dist/sync/state.js +257 -0
- package/dist/sync/state.js.map +1 -0
- package/dist/sync/types.d.ts +275 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +2 -0
- package/dist/sync/types.js.map +1 -0
- package/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @framers/agentos-ext-account-sources
|
|
2
2
|
|
|
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.
|
|
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, and the contracts and pure rules of a durable, resumable synchronization.
|
|
4
4
|
|
|
5
5
|
Install `@framers/agentos-ext-account-sources` with its peer `@framers/agentos` 0.10.40 or later. Node.js 20.19 or later is required. The runtime dependency is `@framers/agentos-ext-public-sources`.
|
|
6
6
|
|
|
@@ -115,10 +115,75 @@ A skip carries one of these reasons:
|
|
|
115
115
|
| `invalid_bounds` | A clock value that is not a nonnegative safe integer, a `receivedAt` before `readStartedAt`, a `maximumCacheMs` that is not a positive safe integer, or a lifetime past the safe-integer range |
|
|
116
116
|
| `expired` | The lifetime ends at or before `receivedAt` |
|
|
117
117
|
|
|
118
|
-
Directive names match in any case and values may be quoted
|
|
118
|
+
Directive names match in any case and values may be quoted; a quoted value may hold commas, as in `private="set-cookie, authorization"`. Other directives, such as `private` and `immutable`, neither grant nor extend a lifetime. The obsolete HTTP date forms are refused rather than parsed.
|
|
119
119
|
|
|
120
120
|
A skip stores nothing: record its reason and keep no content. Store `expiresAt` with the content and check it on every read. Neither a later sync checkpoint nor a second call with the old response extends it; a new read takes a new decision.
|
|
121
121
|
|
|
122
|
+
## Durable synchronization
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import {
|
|
126
|
+
advanceSourceSyncPage, committableSourceCursor, openSourceSyncCycle,
|
|
127
|
+
type SourceSyncPolicy, type SourceSyncWorkSummary,
|
|
128
|
+
} from '@framers/agentos-ext-account-sources';
|
|
129
|
+
|
|
130
|
+
const policy: SourceSyncPolicy = {
|
|
131
|
+
windowMs: 7 * 86_400_000, maxRetainedDocuments: 100, maxHeldCharacters: 2_000_000,
|
|
132
|
+
maxIndexedCharacters: 4_000_000, scanPageSize: 50, maxScanPages: 4, maxCandidates: 200,
|
|
133
|
+
maxChangedPerLease: 50, maxHistoryPagesPerLease: 10, leaseMs: 120_000,
|
|
134
|
+
pollMs: 900_000, manualMinIntervalMs: 60_000, reconcileMs: 86_400_000,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const opened = openSourceSyncCycle({
|
|
138
|
+
cycleId: 'cycle-1', generation: 3, mode: 'incremental', cutoff: Date.now(), fromCursor: 'cursor-41',
|
|
139
|
+
});
|
|
140
|
+
const { checkpoint, enqueueIds } = advanceSourceSyncPage(opened, {
|
|
141
|
+
kind: 'history', ids: ['item-a', 'item-b'], nextPageToken: null, cursor: 'cursor-42',
|
|
142
|
+
}, policy);
|
|
143
|
+
// Store `checkpoint` and queue `enqueueIds` as pending work in one transaction, then read each item.
|
|
144
|
+
|
|
145
|
+
const summary: SourceSyncWorkSummary = {
|
|
146
|
+
cycleId: checkpoint.cycleId, generation: checkpoint.generation, checkpointRevision: checkpoint.revision,
|
|
147
|
+
total: 2, pending: 0, retry: 0, applied: 1, gone: 1, skipped: 0,
|
|
148
|
+
};
|
|
149
|
+
committableSourceCursor(checkpoint, summary); // 'cursor-42'
|
|
150
|
+
```
|
|
151
|
+
|
|
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
|
+
|
|
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.
|
|
155
|
+
|
|
156
|
+
### Connection state
|
|
157
|
+
|
|
158
|
+
`createSourceSyncState(scope, now)` starts a connection in `not_connected` at generation 0. `transitionSourceSync(state, event, now)` answers the next frozen state. It throws `invalid_source_transition` for an event the state does not allow and `source_sync_counter_exhausted` when a counter would pass the safe-integer range.
|
|
159
|
+
|
|
160
|
+
| State | Meaning |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `not_connected` | No grant yet |
|
|
163
|
+
| `connecting` | Authorization in progress |
|
|
164
|
+
| `syncing` | A sync is running |
|
|
165
|
+
| `connected` | Grant held, no sync running |
|
|
166
|
+
| `needs_reconnecting` | The grant was refused or lacks a scope; the cursor and use switches are cleared |
|
|
167
|
+
| `disconnected` | The connection ended; the cursor and use switches are cleared |
|
|
168
|
+
|
|
169
|
+
Pause is the `paused` flag on a connected or syncing connection, not a state: it stops syncs and keeps the cursor. Connecting, grant loss, disconnecting, pause, resume, a policy change and a use change each raise `generation`, so a store can refuse work started under an earlier one. A policy change also clears the cursor, so the next cycle applies the new bounds from a fresh pass. Connecting, pause, resume, a policy change, grant loss and disconnecting set `revalidationRequired`; a successful sync clears it. Disconnecting a disconnected connection, pausing a paused one and resuming an unpaused one answer the same state.
|
|
170
|
+
|
|
171
|
+
`sourceSyncDue(state, policy, now, trigger)` is false unless the connection is connected or syncing, unpaused and at or after any `retryAt`. A `'scheduled'` trigger is then due once `nextSyncAt` is reached; a `'manual'` one when no request was made yet or `manualMinIntervalMs` has passed since the last. A deferred sync keeps the cursor and sets `retryAt`. A `domain_policy` or `invalid_response` failure clears `nextSyncAt`, so no scheduled sync is due until a manual request or another control change sets it.
|
|
172
|
+
|
|
173
|
+
### Cycles and the cursor
|
|
174
|
+
|
|
175
|
+
`openSourceSyncCycle(input)` opens a checkpoint at revision 0 and throws `invalid_source_sync_checkpoint` for an empty or oversized id or anchor, a generation or cutoff that is not a nonnegative safe integer, or an unknown mode. An `incremental` cycle starts with history from the committed cursor; `bootstrap`, `reconcile` and `recovery` start with a scan, from an anchor read before it. `advanceSourceSyncPage(checkpoint, page, policy)` answers the next checkpoint and the ids to queue, without duplicates:
|
|
176
|
+
|
|
177
|
+
- A scan that reaches `maxScanPages` pages or `maxCandidates` ids with more left keeps the first ids in the order given, marks the checkpoint `bounded` and stops. A finished scan moves the cycle to history from the same anchor.
|
|
178
|
+
- A history page records its cursor as the target. The last page, with no next page token, moves the cycle to `apply`.
|
|
179
|
+
- A page of the wrong kind for the phase, a scan page past the bounds or larger than `scanPageSize`, an empty or oversized id, cursor or page token, or a page whose next token is the token it was read with throws `invalid_source_sync_page`.
|
|
180
|
+
|
|
181
|
+
`committableSourceCursor(checkpoint, summary)` answers the target cursor only in `apply` with no page token left, when the summary names the checkpoint's cycle, generation and revision, holds no pending or retry work, and its applied, gone and skipped counts add up to its total. Otherwise it answers null. `isTerminalSourceWork` is true for applied, gone and skipped work.
|
|
182
|
+
|
|
183
|
+
The rules are pure and take no lock: the store that commits a cursor reads the summary from all of the cycle's work under its lease and checkpoint lock, in the transaction that commits it. A page carries no gone list: only a read of the item, an exclusion, expiry or the end of the connection removes content.
|
|
184
|
+
|
|
185
|
+
`new SourceSyncFault(code, retryAt?)` carries a fixed failure code as its message (`source_sync_<code>`), never a provider's text, exposes `code` and `retryAt`, and throws `invalid_source_sync_fault` for an unknown code or a `retryAt` that is not a nonnegative safe integer. `assertSourceSyncPolicy(policy)` throws `invalid_source_sync_policy` unless every policy value is a positive safe integer.
|
|
186
|
+
|
|
122
187
|
## License
|
|
123
188
|
|
|
124
189
|
Apache-2.0. This pack carries a copy of the repository's license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cachePolicy.d.ts","sourceRoot":"","sources":["../src/cachePolicy.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CA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,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC;AAED,iFAAiF;AACjF,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GAAG,UAAU,GAAG,uBAAuB,GACtD,sBAAsB,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE1D,uFAAuF;AACvF,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACnF;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAgEtE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,mBAAmB,CAiD9E"}
|
package/dist/cachePolicy.js
CHANGED
|
@@ -15,13 +15,47 @@ function date(value) {
|
|
|
15
15
|
const parsed = Date.parse(value);
|
|
16
16
|
return integer(parsed) && new Date(parsed).toUTCString() === value ? parsed : null;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Splits a list field value on commas outside quoted strings (RFC 9110, sections 5.6.1.2 and
|
|
20
|
+
* 5.6.4). A quoted string left open answers null.
|
|
21
|
+
*/
|
|
22
|
+
function listMembers(value) {
|
|
23
|
+
const members = [];
|
|
24
|
+
let quoted = false;
|
|
25
|
+
let from = 0;
|
|
26
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
27
|
+
const character = value[index];
|
|
28
|
+
if (quoted && character === '\\') {
|
|
29
|
+
// A quoted-pair: the escaped character neither closes the string nor splits the list.
|
|
30
|
+
index += 1;
|
|
31
|
+
}
|
|
32
|
+
else if (character === '"') {
|
|
33
|
+
quoted = !quoted;
|
|
34
|
+
}
|
|
35
|
+
else if (character === ',' && !quoted) {
|
|
36
|
+
members.push(value.slice(from, index));
|
|
37
|
+
from = index + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (quoted)
|
|
41
|
+
return null;
|
|
42
|
+
members.push(value.slice(from));
|
|
43
|
+
return members;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Cache-Control directives by lower-case name. A quoted value may hold commas; a backslash in it
|
|
47
|
+
* escapes the next character and stays in the value. A malformed or repeated directive, or a
|
|
48
|
+
* quoted value left open, answers null.
|
|
49
|
+
*/
|
|
19
50
|
function directives(value) {
|
|
20
51
|
const found = new Map();
|
|
21
52
|
if (value === null || value.trim() === '')
|
|
22
53
|
return found;
|
|
23
|
-
|
|
24
|
-
|
|
54
|
+
const members = listMembers(value);
|
|
55
|
+
if (members === null)
|
|
56
|
+
return null;
|
|
57
|
+
for (const part of members) {
|
|
58
|
+
const match = /^([a-z][a-z0-9-]*)(?:\s*=\s*(?:"((?:[^"\\]|\\[\s\S])*)"|([^\s",]+)))?$/i.exec(part.trim());
|
|
25
59
|
const name = match?.[1]?.toLowerCase();
|
|
26
60
|
if (!match || !name || found.has(name))
|
|
27
61
|
return null;
|
package/dist/cachePolicy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cachePolicy.js","sourceRoot":"","sources":["../src/cachePolicy.ts"],"names":[],"mappings":"AAkCA,MAAM,OAAO,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACtF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AACzE,MAAM,IAAI,GAAG,CAAC,MAA6B,EAAuB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEhG,iGAAiG;AACjG,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC,OAAO,CAA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AAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC3E,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,eAAe,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACzE,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,GAAG,QAAQ,GAAG,YAAY,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC3E,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACpE,IAAI,SAAS,IAAI,KAAK,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC;AACzE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,7 @@ export * from './readCapped.js';
|
|
|
8
8
|
export * from './limiter.js';
|
|
9
9
|
/** Explicit retention permission and conservative source-cache expiry. */
|
|
10
10
|
export * from './cachePolicy.js';
|
|
11
|
+
/** Durable synchronization contracts and pure state/checkpoint rules. */
|
|
12
|
+
export * from './sync/types.js';
|
|
13
|
+
export * from './sync/state.js';
|
|
11
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAC3B,yDAAyD;AACzD,cAAc,gBAAgB,CAAC;AAC/B,8DAA8D;AAC9D,cAAc,iBAAiB,CAAC;AAChC,oEAAoE;AACpE,cAAc,cAAc,CAAC;AAC7B,0EAA0E;AAC1E,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAC3B,yDAAyD;AACzD,cAAc,gBAAgB,CAAC;AAC/B,8DAA8D;AAC9D,cAAc,iBAAiB,CAAC;AAChC,oEAAoE;AACpE,cAAc,cAAc,CAAC;AAC7B,0EAA0E;AAC1E,cAAc,kBAAkB,CAAC;AACjC,yEAAyE;AACzE,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,7 @@ export * from './readCapped.js';
|
|
|
8
8
|
export * from './limiter.js';
|
|
9
9
|
/** Explicit retention permission and conservative source-cache expiry. */
|
|
10
10
|
export * from './cachePolicy.js';
|
|
11
|
+
/** Durable synchronization contracts and pure state/checkpoint rules. */
|
|
12
|
+
export * from './sync/types.js';
|
|
13
|
+
export * from './sync/state.js';
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAC3B,yDAAyD;AACzD,cAAc,gBAAgB,CAAC;AAC/B,8DAA8D;AAC9D,cAAc,iBAAiB,CAAC;AAChC,oEAAoE;AACpE,cAAc,cAAc,CAAC;AAC7B,0EAA0E;AAC1E,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAC3B,yDAAyD;AACzD,cAAc,gBAAgB,CAAC;AAC/B,8DAA8D;AAC9D,cAAc,iBAAiB,CAAC;AAChC,oEAAoE;AACpE,cAAc,cAAc,CAAC;AAC7B,0EAA0E;AAC1E,cAAc,kBAAkB,CAAC;AACjC,yEAAyE;AACzE,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SourceSyncScope, SourceSyncState, SourceSyncPolicy, SourceSyncTransition, SourceSyncTrigger, SourceSyncFailureCode, SourceSyncCheckpoint, SourceSyncCycleInput, SourceSyncPage, SourceSyncPageApplication, SourceSyncWorkDisposition, SourceSyncWorkSummary } from './types.js';
|
|
2
|
+
/** Fixed failure code only. Never pass provider messages, HTTP bodies or nested causes. */
|
|
3
|
+
export declare class SourceSyncFault extends Error {
|
|
4
|
+
readonly code: SourceSyncFailureCode;
|
|
5
|
+
readonly retryAt: number | null;
|
|
6
|
+
constructor(code: SourceSyncFailureCode, retryAt?: number | null);
|
|
7
|
+
}
|
|
8
|
+
/** Throws `invalid_source_sync_policy` unless every policy value is a positive safe integer. */
|
|
9
|
+
export declare function assertSourceSyncPolicy(policy: SourceSyncPolicy): void;
|
|
10
|
+
/** A new connection in `not_connected` at generation 0. Throws `invalid_source_sync_state` for an empty or oversized key or an invalid clock. */
|
|
11
|
+
export declare function createSourceSyncState(scope: SourceSyncScope, now: number): SourceSyncState;
|
|
12
|
+
/** Pure proposal only; the SQL store authorizes and commits it under its lease/owner lock. */
|
|
13
|
+
export declare function transitionSourceSync(state: SourceSyncState, event: SourceSyncTransition, now: number): SourceSyncState;
|
|
14
|
+
/** Lease existence is a separate atomic SQL check, not something this function authorizes. */
|
|
15
|
+
export declare function sourceSyncDue(state: SourceSyncState, policy: SourceSyncPolicy, now: number, trigger: SourceSyncTrigger): boolean;
|
|
16
|
+
/** Opens a cycle at revision 0: an incremental cycle starts in history, every other mode with a scan. */
|
|
17
|
+
export declare function openSourceSyncCycle(input: SourceSyncCycleInput): SourceSyncCheckpoint;
|
|
18
|
+
/** The store persists this checkpoint and requeues all enqueueIds atomically. */
|
|
19
|
+
export declare function advanceSourceSyncPage(checkpoint: SourceSyncCheckpoint, page: SourceSyncPage, policy: SourceSyncPolicy): SourceSyncPageApplication;
|
|
20
|
+
/** True for applied, gone and skipped work; pending and retry work hold back the cursor. */
|
|
21
|
+
export declare function isTerminalSourceWork(disposition: SourceSyncWorkDisposition): boolean;
|
|
22
|
+
/** No arithmetic or ordering comparison is ever applied to a remote cursor. */
|
|
23
|
+
export declare function committableSourceCursor(checkpoint: SourceSyncCheckpoint, work: SourceSyncWorkSummary): string | null;
|
|
24
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/sync/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAAE,eAAe,EAAqC,gBAAgB,EACrF,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EACpF,oBAAoB,EAAE,cAAc,EAAE,yBAAyB,EAC/D,yBAAyB,EAAE,qBAAqB,EACjD,MAAM,YAAY,CAAC;AAiCpB,2FAA2F;AAC3F,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;gBACpB,IAAI,EAAE,qBAAqB,EAAE,OAAO,GAAE,MAAM,GAAG,IAAW;CASvE;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAOrE;AAED,iJAAiJ;AACjJ,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,CAS1F;AAED,8FAA8F;AAC9F,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,GAC/D,eAAe,CAkGjB;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GACxF,OAAO,CAST;AAED,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,CAWrF;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,oBAAoB,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,GAC/E,yBAAyB,CAqC3B;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,yBAAyB,GAAG,OAAO,CAEpF;AAED,+EAA+E;AAC/E,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,oBAAoB,EAAE,IAAI,EAAE,qBAAqB,GAC5D,MAAM,GAAG,IAAI,CAWf"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
const integer = (n) => Number.isSafeInteger(n) && n >= 0;
|
|
2
|
+
const positive = (n) => integer(n) && n > 0;
|
|
3
|
+
const key = (s) => typeof s === 'string' && s.length > 0 && s.length <= 1_024;
|
|
4
|
+
const token = (s) => s === null || key(s);
|
|
5
|
+
const failures = [
|
|
6
|
+
'network', 'rate_limited', 'provider_unavailable', 'storage_unavailable',
|
|
7
|
+
'grant_rejected', 'insufficient_scope', 'domain_policy', 'history_expired', 'invalid_response', 'cancelled',
|
|
8
|
+
];
|
|
9
|
+
const increment = (n) => {
|
|
10
|
+
if (!integer(n) || !integer(n + 1))
|
|
11
|
+
throw new Error('source_sync_counter_exhausted');
|
|
12
|
+
return n + 1;
|
|
13
|
+
};
|
|
14
|
+
const zeroProgress = () => ({ examined: 0, committed: 0, skipped: 0, bounded: false });
|
|
15
|
+
const noUse = () => ({ searchAskEnabled: false, liveEnabled: false });
|
|
16
|
+
function validUse(use) {
|
|
17
|
+
return typeof use.searchAskEnabled === 'boolean' && typeof use.liveEnabled === 'boolean';
|
|
18
|
+
}
|
|
19
|
+
function validProgress(progress) {
|
|
20
|
+
return integer(progress.examined) && integer(progress.committed) && integer(progress.skipped)
|
|
21
|
+
&& typeof progress.bounded === 'boolean';
|
|
22
|
+
}
|
|
23
|
+
function frozen(state) {
|
|
24
|
+
return Object.freeze({
|
|
25
|
+
...state, scope: Object.freeze({ ...state.scope }),
|
|
26
|
+
use: Object.freeze({ ...state.use }), progress: Object.freeze({ ...state.progress }),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function requireTransition(condition) {
|
|
30
|
+
if (!condition)
|
|
31
|
+
throw new Error('invalid_source_transition');
|
|
32
|
+
}
|
|
33
|
+
/** Fixed failure code only. Never pass provider messages, HTTP bodies or nested causes. */
|
|
34
|
+
export class SourceSyncFault extends Error {
|
|
35
|
+
code;
|
|
36
|
+
retryAt;
|
|
37
|
+
constructor(code, retryAt = null) {
|
|
38
|
+
if (!failures.includes(code) || (retryAt !== null && !integer(retryAt))) {
|
|
39
|
+
throw new Error('invalid_source_sync_fault');
|
|
40
|
+
}
|
|
41
|
+
super(`source_sync_${code}`);
|
|
42
|
+
this.name = 'SourceSyncFault';
|
|
43
|
+
this.code = code;
|
|
44
|
+
this.retryAt = retryAt;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Throws `invalid_source_sync_policy` unless every policy value is a positive safe integer. */
|
|
48
|
+
export function assertSourceSyncPolicy(policy) {
|
|
49
|
+
const values = [
|
|
50
|
+
policy.windowMs, policy.maxRetainedDocuments, policy.maxHeldCharacters, policy.maxIndexedCharacters,
|
|
51
|
+
policy.scanPageSize, policy.maxScanPages, policy.maxCandidates, policy.maxChangedPerLease,
|
|
52
|
+
policy.maxHistoryPagesPerLease, policy.leaseMs, policy.pollMs, policy.manualMinIntervalMs, policy.reconcileMs,
|
|
53
|
+
];
|
|
54
|
+
if (!values.every(positive))
|
|
55
|
+
throw new Error('invalid_source_sync_policy');
|
|
56
|
+
}
|
|
57
|
+
/** A new connection in `not_connected` at generation 0. Throws `invalid_source_sync_state` for an empty or oversized key or an invalid clock. */
|
|
58
|
+
export function createSourceSyncState(scope, now) {
|
|
59
|
+
if (![scope.tenantId, scope.ownerId, scope.connectionId].every((value) => key(value) && value.length <= 512) || !integer(now)) {
|
|
60
|
+
throw new Error('invalid_source_sync_state');
|
|
61
|
+
}
|
|
62
|
+
return frozen({
|
|
63
|
+
scope, status: 'not_connected', generation: 0, revision: 0, paused: false, revalidationRequired: true,
|
|
64
|
+
use: noUse(), cursor: null, progress: zeroProgress(), lastSyncAt: null,
|
|
65
|
+
lastRequestedAt: null, nextSyncAt: null, retryAt: null, error: null, updatedAt: now,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Pure proposal only; the SQL store authorizes and commits it under its lease/owner lock. */
|
|
69
|
+
export function transitionSourceSync(state, event, now) {
|
|
70
|
+
requireTransition(integer(now) && integer(state.generation) && integer(state.revision));
|
|
71
|
+
const active = state.status === 'connected' || state.status === 'syncing';
|
|
72
|
+
let next = { ...state, revision: increment(state.revision), updatedAt: now };
|
|
73
|
+
switch (event.type) {
|
|
74
|
+
case 'connect_started':
|
|
75
|
+
requireTransition(['not_connected', 'disconnected', 'needs_reconnecting'].includes(state.status));
|
|
76
|
+
next = {
|
|
77
|
+
...next, status: 'connecting', generation: increment(state.generation), paused: false, revalidationRequired: true,
|
|
78
|
+
use: noUse(), cursor: null, progress: zeroProgress(), lastSyncAt: null,
|
|
79
|
+
lastRequestedAt: null, nextSyncAt: null, retryAt: null, error: null,
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
case 'grant_ready':
|
|
83
|
+
requireTransition(state.status === 'connecting' && validUse(event.use));
|
|
84
|
+
next = { ...next, status: 'connected', use: event.use, nextSyncAt: now };
|
|
85
|
+
break;
|
|
86
|
+
case 'manual_requested':
|
|
87
|
+
requireTransition(active && !state.paused);
|
|
88
|
+
next = { ...next, lastRequestedAt: now, nextSyncAt: now };
|
|
89
|
+
break;
|
|
90
|
+
case 'sync_started':
|
|
91
|
+
requireTransition(active && !state.paused && (state.retryAt === null || now >= state.retryAt));
|
|
92
|
+
next = { ...next, status: 'syncing', retryAt: null, error: null, progress: zeroProgress() };
|
|
93
|
+
break;
|
|
94
|
+
case 'sync_progress':
|
|
95
|
+
requireTransition(state.status === 'syncing' && !state.paused && validProgress(event.progress));
|
|
96
|
+
next = { ...next, progress: event.progress };
|
|
97
|
+
break;
|
|
98
|
+
case 'sync_succeeded':
|
|
99
|
+
requireTransition(state.status === 'syncing' && !state.paused && key(event.cursor)
|
|
100
|
+
&& integer(event.nextSyncAt) && event.nextSyncAt >= now);
|
|
101
|
+
next = {
|
|
102
|
+
...next, status: 'connected', cursor: event.cursor, lastSyncAt: now,
|
|
103
|
+
nextSyncAt: event.nextSyncAt, retryAt: null, error: null, revalidationRequired: false,
|
|
104
|
+
};
|
|
105
|
+
break;
|
|
106
|
+
case 'sync_deferred':
|
|
107
|
+
requireTransition(state.status === 'syncing' && !state.paused
|
|
108
|
+
&& integer(event.retryAt) && event.retryAt > now
|
|
109
|
+
&& ['network', 'rate_limited', 'provider_unavailable', 'storage_unavailable'].includes(event.reason));
|
|
110
|
+
next = { ...next, status: 'connected', retryAt: event.retryAt, nextSyncAt: event.retryAt, error: event.reason };
|
|
111
|
+
break;
|
|
112
|
+
case 'sync_failed':
|
|
113
|
+
requireTransition(active && ['domain_policy', 'invalid_response'].includes(event.reason));
|
|
114
|
+
next = { ...next, status: 'connected', error: event.reason, nextSyncAt: null, retryAt: null };
|
|
115
|
+
break;
|
|
116
|
+
case 'grant_lost':
|
|
117
|
+
requireTransition((active || state.status === 'connecting')
|
|
118
|
+
&& ['grant_rejected', 'insufficient_scope'].includes(event.reason));
|
|
119
|
+
next = {
|
|
120
|
+
...next, status: 'needs_reconnecting', generation: increment(state.generation),
|
|
121
|
+
cursor: null, use: noUse(), paused: false, progress: zeroProgress(), revalidationRequired: true,
|
|
122
|
+
nextSyncAt: null, retryAt: null, error: event.reason,
|
|
123
|
+
};
|
|
124
|
+
break;
|
|
125
|
+
case 'disconnect':
|
|
126
|
+
if (state.status === 'disconnected')
|
|
127
|
+
return state;
|
|
128
|
+
next = {
|
|
129
|
+
...next, status: 'disconnected', generation: increment(state.generation),
|
|
130
|
+
cursor: null, use: noUse(), paused: false, progress: zeroProgress(), revalidationRequired: true,
|
|
131
|
+
nextSyncAt: null, retryAt: null, error: null,
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case 'pause':
|
|
135
|
+
requireTransition(active);
|
|
136
|
+
if (state.paused)
|
|
137
|
+
return state;
|
|
138
|
+
next = {
|
|
139
|
+
...next, status: 'connected', generation: increment(state.generation),
|
|
140
|
+
paused: true, nextSyncAt: null, revalidationRequired: true,
|
|
141
|
+
};
|
|
142
|
+
break;
|
|
143
|
+
case 'resume':
|
|
144
|
+
requireTransition(active);
|
|
145
|
+
if (!state.paused)
|
|
146
|
+
return state;
|
|
147
|
+
next = {
|
|
148
|
+
...next, status: 'connected', generation: increment(state.generation),
|
|
149
|
+
paused: false, nextSyncAt: Math.max(now, state.retryAt ?? now), revalidationRequired: true,
|
|
150
|
+
};
|
|
151
|
+
break;
|
|
152
|
+
case 'policy_changed':
|
|
153
|
+
requireTransition(active);
|
|
154
|
+
next = {
|
|
155
|
+
...next, status: 'connected', generation: increment(state.generation), cursor: null, revalidationRequired: true,
|
|
156
|
+
nextSyncAt: state.paused ? null : Math.max(now, state.retryAt ?? now), progress: zeroProgress(),
|
|
157
|
+
};
|
|
158
|
+
break;
|
|
159
|
+
case 'use_changed':
|
|
160
|
+
requireTransition(active && validUse(event.use));
|
|
161
|
+
next = {
|
|
162
|
+
...next, status: 'connected', generation: increment(state.generation), use: event.use,
|
|
163
|
+
nextSyncAt: state.paused ? null : Math.max(now, state.retryAt ?? now),
|
|
164
|
+
};
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error('invalid_source_transition');
|
|
168
|
+
}
|
|
169
|
+
return frozen(next);
|
|
170
|
+
}
|
|
171
|
+
/** Lease existence is a separate atomic SQL check, not something this function authorizes. */
|
|
172
|
+
export function sourceSyncDue(state, policy, now, trigger) {
|
|
173
|
+
assertSourceSyncPolicy(policy);
|
|
174
|
+
if (!integer(now) || !['connected', 'syncing'].includes(state.status) || state.paused
|
|
175
|
+
|| (state.retryAt !== null && now < state.retryAt))
|
|
176
|
+
return false;
|
|
177
|
+
if (trigger === 'manual') {
|
|
178
|
+
return state.lastRequestedAt === null || (now >= state.lastRequestedAt
|
|
179
|
+
&& now - state.lastRequestedAt >= policy.manualMinIntervalMs);
|
|
180
|
+
}
|
|
181
|
+
return trigger === 'scheduled' && state.nextSyncAt !== null && now >= state.nextSyncAt;
|
|
182
|
+
}
|
|
183
|
+
/** Opens a cycle at revision 0: an incremental cycle starts in history, every other mode with a scan. */
|
|
184
|
+
export function openSourceSyncCycle(input) {
|
|
185
|
+
if (!key(input.cycleId) || !integer(input.generation) || !integer(input.cutoff)
|
|
186
|
+
|| !key(input.fromCursor) || !['bootstrap', 'incremental', 'reconcile', 'recovery'].includes(input.mode)) {
|
|
187
|
+
throw new Error('invalid_source_sync_checkpoint');
|
|
188
|
+
}
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
cycleId: input.cycleId, generation: input.generation, revision: 0,
|
|
191
|
+
mode: input.mode, phase: input.mode === 'incremental' ? 'history' : 'scan',
|
|
192
|
+
cutoff: input.cutoff, fromCursor: input.fromCursor, nextPageToken: null, targetCursor: null,
|
|
193
|
+
scanPages: 0, candidates: 0, historyPages: 0, bounded: false,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/** The store persists this checkpoint and requeues all enqueueIds atomically. */
|
|
197
|
+
export function advanceSourceSyncPage(checkpoint, page, policy) {
|
|
198
|
+
assertSourceSyncPolicy(policy);
|
|
199
|
+
const fail = () => { throw new Error('invalid_source_sync_page'); };
|
|
200
|
+
if (!key(checkpoint.cycleId) || !key(checkpoint.fromCursor) || !integer(checkpoint.generation)
|
|
201
|
+
|| !integer(checkpoint.cutoff) || !integer(checkpoint.revision) || !integer(checkpoint.scanPages) || !integer(checkpoint.candidates)
|
|
202
|
+
|| !integer(checkpoint.historyPages) || !token(page.nextPageToken) || !page.ids.every(key)
|
|
203
|
+
|| (page.nextPageToken !== null && page.nextPageToken === checkpoint.nextPageToken))
|
|
204
|
+
fail();
|
|
205
|
+
if (checkpoint.phase === 'scan' && page.kind === 'scan') {
|
|
206
|
+
if (checkpoint.scanPages >= policy.maxScanPages || checkpoint.candidates >= policy.maxCandidates
|
|
207
|
+
|| page.ids.length > policy.scanPageSize)
|
|
208
|
+
fail();
|
|
209
|
+
const remaining = policy.maxCandidates - checkpoint.candidates;
|
|
210
|
+
const selected = page.ids.slice(0, remaining);
|
|
211
|
+
const scanPages = increment(checkpoint.scanPages);
|
|
212
|
+
const candidates = checkpoint.candidates + selected.length;
|
|
213
|
+
const bounded = selected.length < page.ids.length || (page.nextPageToken !== null
|
|
214
|
+
&& (scanPages >= policy.maxScanPages || candidates >= policy.maxCandidates));
|
|
215
|
+
const done = page.nextPageToken === null || bounded;
|
|
216
|
+
return Object.freeze({
|
|
217
|
+
enqueueIds: Object.freeze([...new Set(selected)]),
|
|
218
|
+
checkpoint: Object.freeze({
|
|
219
|
+
...checkpoint, revision: increment(checkpoint.revision), scanPages, candidates,
|
|
220
|
+
phase: done ? 'history' : 'scan', nextPageToken: done ? null : page.nextPageToken,
|
|
221
|
+
targetCursor: null, bounded: checkpoint.bounded || bounded,
|
|
222
|
+
}),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (checkpoint.phase === 'history' && page.kind === 'history' && key(page.cursor)) {
|
|
226
|
+
return Object.freeze({
|
|
227
|
+
enqueueIds: Object.freeze([...new Set(page.ids)]),
|
|
228
|
+
checkpoint: Object.freeze({
|
|
229
|
+
...checkpoint, revision: increment(checkpoint.revision), historyPages: increment(checkpoint.historyPages),
|
|
230
|
+
phase: page.nextPageToken === null ? 'apply' : 'history',
|
|
231
|
+
nextPageToken: page.nextPageToken, targetCursor: page.cursor,
|
|
232
|
+
}),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return fail();
|
|
236
|
+
}
|
|
237
|
+
/** True for applied, gone and skipped work; pending and retry work hold back the cursor. */
|
|
238
|
+
export function isTerminalSourceWork(disposition) {
|
|
239
|
+
return disposition.kind === 'applied' || disposition.kind === 'gone' || disposition.kind === 'skipped';
|
|
240
|
+
}
|
|
241
|
+
/** No arithmetic or ordering comparison is ever applied to a remote cursor. */
|
|
242
|
+
export function committableSourceCursor(checkpoint, work) {
|
|
243
|
+
if (!integer(checkpoint.generation) || !integer(checkpoint.revision)
|
|
244
|
+
|| checkpoint.phase !== 'apply' || checkpoint.nextPageToken !== null
|
|
245
|
+
|| checkpoint.targetCursor === null || !key(checkpoint.targetCursor)
|
|
246
|
+
|| work.cycleId !== checkpoint.cycleId || work.generation !== checkpoint.generation
|
|
247
|
+
|| work.checkpointRevision !== checkpoint.revision)
|
|
248
|
+
return null;
|
|
249
|
+
const counts = [work.total, work.pending, work.retry, work.applied, work.gone, work.skipped];
|
|
250
|
+
if (!counts.every(integer) || work.pending !== 0 || work.retry !== 0)
|
|
251
|
+
return null;
|
|
252
|
+
const sum = work.applied + work.gone + work.skipped;
|
|
253
|
+
if (!integer(sum) || sum !== work.total)
|
|
254
|
+
return null;
|
|
255
|
+
return checkpoint.targetCursor;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/sync/state.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,MAA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C;AAED,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CACrC,UAAgC,EAAE,IAA2B;IAE7D,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;WAC/D,UAAU,CAAC,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,aAAa,KAAK,IAAI;WACjE,UAAU,CAAC,YAAY,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;WACjE,IAAI,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,CAAC,UAAU;WAChF,IAAI,CAAC,kBAAkB,KAAK,UAAU,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAClE,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;IACpD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,UAAU,CAAC,YAAY,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import type { AccountSourceConnector, SourceRead } from '../types.js';
|
|
2
|
+
import type { SourceCacheDecision, SourceCacheSkipReason } from '../cachePolicy.js';
|
|
3
|
+
/** Opaque host-owned keys. Authentication is supplied by the host, never by provider ids. */
|
|
4
|
+
export interface SourceSyncScope {
|
|
5
|
+
readonly tenantId: string;
|
|
6
|
+
readonly ownerId: string;
|
|
7
|
+
readonly connectionId: string;
|
|
8
|
+
}
|
|
9
|
+
/** The six connection states a host shows. Pause is the separate `paused` flag, not a state. */
|
|
10
|
+
export type SourceSyncStatus = 'not_connected' | 'connecting' | 'syncing' | 'connected' | 'needs_reconnecting' | 'disconnected';
|
|
11
|
+
/** The use switches a host applies to a connection's content: search and questions, and live hints. */
|
|
12
|
+
export interface SourceSyncUse {
|
|
13
|
+
readonly searchAskEnabled: boolean;
|
|
14
|
+
readonly liveEnabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Transient failures: the committed cursor stays and a later attempt is scheduled. */
|
|
17
|
+
export type SourceSyncRetryReason = 'network' | 'rate_limited' | 'provider_unavailable' | 'storage_unavailable';
|
|
18
|
+
/** Fixed failure codes; a code carries no provider message or response body. */
|
|
19
|
+
export type SourceSyncFailureCode = SourceSyncRetryReason | 'grant_rejected' | 'insufficient_scope' | 'domain_policy' | 'history_expired' | 'invalid_response' | 'cancelled';
|
|
20
|
+
/** Fixed reasons a source is deliberately not retained: cache refusals and selection, decoding, structure and allowance limits. */
|
|
21
|
+
export type SourceSyncSkipReason = SourceCacheSkipReason | 'excluded' | 'out_of_window' | 'excluded_label' | 'no_eligible_content' | 'response_too_large' | 'structure_limit' | 'unsupported_charset' | 'invalid_encoding' | 'document_limit' | 'held_limit' | 'indexing_limit';
|
|
22
|
+
/** Counts describe this connection; they carry no remote response estimates or ids. */
|
|
23
|
+
export interface SourceSyncProgress {
|
|
24
|
+
readonly examined: number;
|
|
25
|
+
readonly committed: number;
|
|
26
|
+
readonly skipped: number;
|
|
27
|
+
readonly bounded: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** One connection's durable state. Each control change that fences earlier work raises `generation`. */
|
|
30
|
+
export interface SourceSyncState {
|
|
31
|
+
readonly scope: SourceSyncScope;
|
|
32
|
+
readonly status: SourceSyncStatus;
|
|
33
|
+
readonly generation: number;
|
|
34
|
+
readonly revision: number;
|
|
35
|
+
readonly paused: boolean;
|
|
36
|
+
readonly revalidationRequired: boolean;
|
|
37
|
+
readonly use: SourceSyncUse;
|
|
38
|
+
readonly cursor: string | null;
|
|
39
|
+
readonly progress: SourceSyncProgress;
|
|
40
|
+
readonly lastSyncAt: number | null;
|
|
41
|
+
readonly lastRequestedAt: number | null;
|
|
42
|
+
readonly nextSyncAt: number | null;
|
|
43
|
+
readonly retryAt: number | null;
|
|
44
|
+
readonly error: SourceSyncFailureCode | null;
|
|
45
|
+
readonly updatedAt: number;
|
|
46
|
+
}
|
|
47
|
+
/** Values are policy choices. This library does not assert provider service limits. */
|
|
48
|
+
export interface SourceSyncPolicy {
|
|
49
|
+
readonly windowMs: number;
|
|
50
|
+
readonly maxRetainedDocuments: number;
|
|
51
|
+
readonly maxHeldCharacters: number;
|
|
52
|
+
readonly maxIndexedCharacters: number;
|
|
53
|
+
readonly scanPageSize: number;
|
|
54
|
+
readonly maxScanPages: number;
|
|
55
|
+
readonly maxCandidates: number;
|
|
56
|
+
readonly maxChangedPerLease: number;
|
|
57
|
+
readonly maxHistoryPagesPerLease: number;
|
|
58
|
+
readonly leaseMs: number;
|
|
59
|
+
readonly pollMs: number;
|
|
60
|
+
readonly manualMinIntervalMs: number;
|
|
61
|
+
readonly reconcileMs: number;
|
|
62
|
+
}
|
|
63
|
+
/** Owner epoch is checked separately through the released core derivation fence. */
|
|
64
|
+
export interface SourceSyncLease {
|
|
65
|
+
readonly scope: SourceSyncScope;
|
|
66
|
+
readonly generation: number;
|
|
67
|
+
readonly token: string;
|
|
68
|
+
readonly expiresAt: number;
|
|
69
|
+
}
|
|
70
|
+
/** Why a cycle runs: a first pass, history from the committed cursor, a reconciliation pass, or recovery after expired history. */
|
|
71
|
+
export type SourceSyncMode = 'bootstrap' | 'incremental' | 'reconcile' | 'recovery';
|
|
72
|
+
/** Where a cycle stands: a bounded scan, history replay, or application of the queued work. */
|
|
73
|
+
export type SourceSyncPhase = 'scan' | 'history' | 'apply';
|
|
74
|
+
/** A cycle's durable resume point. Cursors and page tokens are opaque strings. */
|
|
75
|
+
export interface SourceSyncCheckpoint {
|
|
76
|
+
readonly cycleId: string;
|
|
77
|
+
readonly generation: number;
|
|
78
|
+
readonly revision: number;
|
|
79
|
+
readonly mode: SourceSyncMode;
|
|
80
|
+
readonly phase: SourceSyncPhase;
|
|
81
|
+
readonly cutoff: number;
|
|
82
|
+
/** Profile anchor before scan, or previously committed cursor for incremental work. */
|
|
83
|
+
readonly fromCursor: string;
|
|
84
|
+
/** Resume metadata only. Null at phase boundaries, never a committed history id. */
|
|
85
|
+
readonly nextPageToken: string | null;
|
|
86
|
+
readonly targetCursor: string | null;
|
|
87
|
+
readonly scanPages: number;
|
|
88
|
+
readonly candidates: number;
|
|
89
|
+
readonly historyPages: number;
|
|
90
|
+
readonly bounded: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** What opening a cycle takes: its id, the connection generation, mode, cutoff and starting anchor. */
|
|
93
|
+
export interface SourceSyncCycleInput {
|
|
94
|
+
readonly cycleId: string;
|
|
95
|
+
readonly generation: number;
|
|
96
|
+
readonly mode: SourceSyncMode;
|
|
97
|
+
readonly cutoff: number;
|
|
98
|
+
readonly fromCursor: string;
|
|
99
|
+
}
|
|
100
|
+
/** One page of a bounded enumeration: candidate ids and the next page's token. */
|
|
101
|
+
export interface SourceSyncScanPage {
|
|
102
|
+
readonly kind: 'scan';
|
|
103
|
+
readonly ids: readonly string[];
|
|
104
|
+
readonly nextPageToken: string | null;
|
|
105
|
+
}
|
|
106
|
+
/** One page of history: affected ids, the next page's token and the cursor this page reached. */
|
|
107
|
+
export interface SourceSyncHistoryPage {
|
|
108
|
+
readonly kind: 'history';
|
|
109
|
+
readonly ids: readonly string[];
|
|
110
|
+
readonly nextPageToken: string | null;
|
|
111
|
+
readonly cursor: string;
|
|
112
|
+
}
|
|
113
|
+
/** Either kind of page a provider answers. */
|
|
114
|
+
export type SourceSyncPage = SourceSyncScanPage | SourceSyncHistoryPage;
|
|
115
|
+
/** The checkpoint a page produces and the ids it queues. */
|
|
116
|
+
export interface SourceSyncPageApplication {
|
|
117
|
+
readonly checkpoint: SourceSyncCheckpoint;
|
|
118
|
+
/** Upsert pending reads in the same transaction as this checkpoint revision. */
|
|
119
|
+
readonly enqueueIds: readonly string[];
|
|
120
|
+
}
|
|
121
|
+
/** A queued source's outcome. Applied, gone and skipped are terminal; pending and retry are not. */
|
|
122
|
+
export type SourceSyncWorkDisposition = {
|
|
123
|
+
readonly kind: 'pending';
|
|
124
|
+
} | {
|
|
125
|
+
readonly kind: 'retry';
|
|
126
|
+
readonly reason: SourceSyncRetryReason;
|
|
127
|
+
readonly retryAt: number;
|
|
128
|
+
} | {
|
|
129
|
+
readonly kind: 'applied';
|
|
130
|
+
readonly version: string;
|
|
131
|
+
} | {
|
|
132
|
+
readonly kind: 'gone';
|
|
133
|
+
} | {
|
|
134
|
+
readonly kind: 'skipped';
|
|
135
|
+
readonly reason: SourceSyncSkipReason;
|
|
136
|
+
};
|
|
137
|
+
/** One durable work row: ids, attempts and a disposition, never source content. */
|
|
138
|
+
export interface SourceSyncWork {
|
|
139
|
+
readonly cycleId: string;
|
|
140
|
+
readonly generation: number;
|
|
141
|
+
readonly sourceId: string;
|
|
142
|
+
/** Re-discovery on a new page invalidates an earlier applied/read result. */
|
|
143
|
+
readonly discoveredRevision: number;
|
|
144
|
+
readonly attempts: number;
|
|
145
|
+
readonly disposition: SourceSyncWorkDisposition;
|
|
146
|
+
}
|
|
147
|
+
/** Complete fresh database aggregate, computed with the checkpoint under its lease lock. */
|
|
148
|
+
export interface SourceSyncWorkSummary {
|
|
149
|
+
readonly cycleId: string;
|
|
150
|
+
readonly generation: number;
|
|
151
|
+
readonly checkpointRevision: number;
|
|
152
|
+
readonly total: number;
|
|
153
|
+
readonly pending: number;
|
|
154
|
+
readonly retry: number;
|
|
155
|
+
readonly applied: number;
|
|
156
|
+
readonly gone: number;
|
|
157
|
+
readonly skipped: number;
|
|
158
|
+
}
|
|
159
|
+
/** Offsets count UTF-16 code units in the sanitized SourceRead.content.text. */
|
|
160
|
+
export interface SourceSyncMessageSpan {
|
|
161
|
+
readonly messageId: string;
|
|
162
|
+
readonly start: number;
|
|
163
|
+
readonly end: number;
|
|
164
|
+
readonly receivedAt: number;
|
|
165
|
+
readonly windowExpiresAt: number;
|
|
166
|
+
readonly truncated: boolean;
|
|
167
|
+
}
|
|
168
|
+
/** A JSON value for document metadata. */
|
|
169
|
+
export type SourceSyncJson = null | boolean | number | string | readonly SourceSyncJson[] | {
|
|
170
|
+
readonly [key: string]: SourceSyncJson;
|
|
171
|
+
};
|
|
172
|
+
/** Normalized, sanitized content only; transient provider responses never enter this shape. */
|
|
173
|
+
export interface SourceSyncDocument {
|
|
174
|
+
readonly read: SourceRead & {
|
|
175
|
+
readonly content: {
|
|
176
|
+
readonly text: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
readonly messages: readonly SourceSyncMessageSpan[];
|
|
180
|
+
readonly metadata: Readonly<Record<string, SourceSyncJson>>;
|
|
181
|
+
readonly activityAt: number;
|
|
182
|
+
readonly contentHash: string;
|
|
183
|
+
readonly cache: Extract<SourceCacheDecision, {
|
|
184
|
+
kind: 'cache';
|
|
185
|
+
}>;
|
|
186
|
+
}
|
|
187
|
+
/** What reading one queued source answers: a document, gone, a deliberate skip or a retry. */
|
|
188
|
+
export type SourceSyncReadResult = {
|
|
189
|
+
readonly kind: 'document';
|
|
190
|
+
readonly document: SourceSyncDocument;
|
|
191
|
+
} | {
|
|
192
|
+
readonly kind: 'gone';
|
|
193
|
+
readonly id: string;
|
|
194
|
+
} | {
|
|
195
|
+
readonly kind: 'skipped';
|
|
196
|
+
readonly id: string;
|
|
197
|
+
readonly reason: SourceSyncSkipReason;
|
|
198
|
+
} | {
|
|
199
|
+
readonly kind: 'retry';
|
|
200
|
+
readonly id: string;
|
|
201
|
+
readonly reason: SourceSyncRetryReason;
|
|
202
|
+
readonly retryAt: number;
|
|
203
|
+
};
|
|
204
|
+
/** Provider request context is process memory, never a serialized queued HTTP request. */
|
|
205
|
+
export interface SourceSyncRequest {
|
|
206
|
+
readonly scope: SourceSyncScope;
|
|
207
|
+
readonly generation: number;
|
|
208
|
+
readonly cycleId: string;
|
|
209
|
+
readonly cutoff: number;
|
|
210
|
+
readonly policy: SourceSyncPolicy;
|
|
211
|
+
readonly signal?: AbortSignal;
|
|
212
|
+
}
|
|
213
|
+
/** One instance is bound to one grant. These calls do no database commit. */
|
|
214
|
+
export interface AccountSourceSyncProvider {
|
|
215
|
+
readonly kind: string;
|
|
216
|
+
begin(request: SourceSyncRequest): Promise<string>;
|
|
217
|
+
scanPage(request: SourceSyncRequest, pageToken: string | null): Promise<SourceSyncScanPage>;
|
|
218
|
+
historyPage(request: SourceSyncRequest, fromCursor: string, pageToken: string | null): Promise<SourceSyncHistoryPage>;
|
|
219
|
+
readSource(request: SourceSyncRequest, sourceId: string): Promise<SourceSyncReadResult>;
|
|
220
|
+
}
|
|
221
|
+
/** Optional capability. An empty selection in the original interface keeps its original meaning. */
|
|
222
|
+
export interface ResumableAccountSourceConnector extends AccountSourceConnector {
|
|
223
|
+
readonly sync: AccountSourceSyncProvider;
|
|
224
|
+
}
|
|
225
|
+
/** A safe event sink accepts only these fields. Scope and provider payloads are excluded. */
|
|
226
|
+
export interface SourceSyncEvent {
|
|
227
|
+
readonly kind: 'source_sync';
|
|
228
|
+
readonly state: 'started' | 'progress' | 'yielded' | 'succeeded' | 'retry' | 'reconnect' | 'purged';
|
|
229
|
+
readonly n: number;
|
|
230
|
+
readonly ms?: number;
|
|
231
|
+
}
|
|
232
|
+
/** Receives content-free sync events. */
|
|
233
|
+
export type SourceSyncEventSink = (event: SourceSyncEvent) => void;
|
|
234
|
+
/** Whether a sync was scheduled or asked for by the person. */
|
|
235
|
+
export type SourceSyncTrigger = 'scheduled' | 'manual';
|
|
236
|
+
/** The events that move a connection between states. */
|
|
237
|
+
export type SourceSyncTransition = {
|
|
238
|
+
readonly type: 'connect_started';
|
|
239
|
+
} | {
|
|
240
|
+
readonly type: 'grant_ready';
|
|
241
|
+
readonly use: SourceSyncUse;
|
|
242
|
+
} | {
|
|
243
|
+
readonly type: 'manual_requested';
|
|
244
|
+
} | {
|
|
245
|
+
readonly type: 'sync_started';
|
|
246
|
+
} | {
|
|
247
|
+
readonly type: 'sync_progress';
|
|
248
|
+
readonly progress: SourceSyncProgress;
|
|
249
|
+
} | {
|
|
250
|
+
readonly type: 'sync_succeeded';
|
|
251
|
+
readonly cursor: string;
|
|
252
|
+
readonly nextSyncAt: number;
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: 'sync_deferred';
|
|
255
|
+
readonly reason: SourceSyncRetryReason;
|
|
256
|
+
readonly retryAt: number;
|
|
257
|
+
} | {
|
|
258
|
+
readonly type: 'sync_failed';
|
|
259
|
+
readonly reason: 'domain_policy' | 'invalid_response';
|
|
260
|
+
} | {
|
|
261
|
+
readonly type: 'grant_lost';
|
|
262
|
+
readonly reason: 'grant_rejected' | 'insufficient_scope';
|
|
263
|
+
} | {
|
|
264
|
+
readonly type: 'disconnect';
|
|
265
|
+
} | {
|
|
266
|
+
readonly type: 'pause';
|
|
267
|
+
} | {
|
|
268
|
+
readonly type: 'resume';
|
|
269
|
+
} | {
|
|
270
|
+
readonly type: 'policy_changed';
|
|
271
|
+
} | {
|
|
272
|
+
readonly type: 'use_changed';
|
|
273
|
+
readonly use: SourceSyncUse;
|
|
274
|
+
};
|
|
275
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MA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;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACnC;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":""}
|
package/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
3
|
"id": "com.framers.research.account-sources",
|
|
4
4
|
"name": "Account Sources",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"description": "A person's own accounts as sources: connector interfaces, passage attribution, capped reads and a shared limiter",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Frame",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@framers/agentos-ext-account-sources",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A person's own accounts as sources: connector interfaces, passage attribution, capped reads and a shared limiter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|