@substrat-run/adapter-cloudflare 0.215.0 → 0.217.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.
Files changed (83) hide show
  1. package/dist/broker-telemetry.d.ts +20 -0
  2. package/dist/broker-telemetry.d.ts.map +1 -0
  3. package/dist/broker-telemetry.js +29 -0
  4. package/dist/broker-telemetry.js.map +1 -0
  5. package/dist/connection-sweep-do.d.ts +83 -0
  6. package/dist/connection-sweep-do.d.ts.map +1 -0
  7. package/dist/connection-sweep-do.js +89 -0
  8. package/dist/connection-sweep-do.js.map +1 -0
  9. package/dist/control-plane-do.d.ts +54 -43
  10. package/dist/control-plane-do.d.ts.map +1 -1
  11. package/dist/control-plane-do.js +131 -80
  12. package/dist/control-plane-do.js.map +1 -1
  13. package/dist/delivery-broker-do.d.ts +94 -0
  14. package/dist/delivery-broker-do.d.ts.map +1 -0
  15. package/dist/delivery-broker-do.js +172 -0
  16. package/dist/delivery-broker-do.js.map +1 -0
  17. package/dist/delivery-handoff.d.ts +46 -0
  18. package/dist/delivery-handoff.d.ts.map +1 -0
  19. package/dist/delivery-handoff.js +61 -0
  20. package/dist/delivery-handoff.js.map +1 -0
  21. package/dist/directory-mirror-apply.d.ts +59 -0
  22. package/dist/directory-mirror-apply.d.ts.map +1 -0
  23. package/dist/directory-mirror-apply.js +158 -0
  24. package/dist/directory-mirror-apply.js.map +1 -0
  25. package/dist/directory-mirror-claims.d.ts +77 -0
  26. package/dist/directory-mirror-claims.d.ts.map +1 -0
  27. package/dist/directory-mirror-claims.js +129 -0
  28. package/dist/directory-mirror-claims.js.map +1 -0
  29. package/dist/directory-mirror.d.ts +201 -0
  30. package/dist/directory-mirror.d.ts.map +1 -0
  31. package/dist/directory-mirror.js +557 -0
  32. package/dist/directory-mirror.js.map +1 -0
  33. package/dist/directory-objects.d.ts +24 -0
  34. package/dist/directory-objects.d.ts.map +1 -1
  35. package/dist/directory-objects.js +125 -1
  36. package/dist/directory-objects.js.map +1 -1
  37. package/dist/directory-placement.d.ts +17 -0
  38. package/dist/directory-placement.d.ts.map +1 -1
  39. package/dist/directory-placement.js +28 -2
  40. package/dist/directory-placement.js.map +1 -1
  41. package/dist/directory-split-inventory.d.ts +4 -1
  42. package/dist/directory-split-inventory.d.ts.map +1 -1
  43. package/dist/directory-split-inventory.js +7 -1
  44. package/dist/directory-split-inventory.js.map +1 -1
  45. package/dist/host.d.ts +11 -1
  46. package/dist/host.d.ts.map +1 -1
  47. package/dist/host.js +44 -5
  48. package/dist/host.js.map +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +4 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/peer-call-target.d.ts +61 -0
  54. package/dist/peer-call-target.d.ts.map +1 -0
  55. package/dist/peer-call-target.js +98 -0
  56. package/dist/peer-call-target.js.map +1 -0
  57. package/dist/reconcile-on-wake.d.ts.map +1 -1
  58. package/dist/reconcile-on-wake.js +5 -3
  59. package/dist/reconcile-on-wake.js.map +1 -1
  60. package/dist/route-read-model-publisher.d.ts +29 -4
  61. package/dist/route-read-model-publisher.d.ts.map +1 -1
  62. package/dist/route-read-model-publisher.js +137 -3
  63. package/dist/route-read-model-publisher.js.map +1 -1
  64. package/dist/route-read-model.d.ts +75 -1
  65. package/dist/route-read-model.d.ts.map +1 -1
  66. package/dist/route-read-model.js +118 -0
  67. package/dist/route-read-model.js.map +1 -1
  68. package/dist/route-resolver.d.ts +33 -5
  69. package/dist/route-resolver.d.ts.map +1 -1
  70. package/dist/route-resolver.js +130 -70
  71. package/dist/route-resolver.js.map +1 -1
  72. package/dist/scope-do.d.ts +11 -0
  73. package/dist/scope-do.d.ts.map +1 -1
  74. package/dist/scope-do.js +292 -21
  75. package/dist/scope-do.js.map +1 -1
  76. package/dist/scope-sweeper-do.d.ts +12 -2
  77. package/dist/scope-sweeper-do.d.ts.map +1 -1
  78. package/dist/scope-sweeper-do.js.map +1 -1
  79. package/dist/scope-work.d.ts +1 -1
  80. package/dist/scope-work.d.ts.map +1 -1
  81. package/dist/scope-work.js +1 -0
  82. package/dist/scope-work.js.map +1 -1
  83. package/package.json +9 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-mirror-apply.js","sourceRoot":"","sources":["../src/directory-mirror-apply.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEpG,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B;;;;;;;mBAOiB;IACjB,iGAAiG;IACjG,6GAA6G;IAC7G;;;;;;;;mBAQiB;CAClB,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,uDAAuD;AACvD,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAuB/E,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAqC,CAAC;AAClE,SAAS,MAAM,CAAC,GAAe,EAAE,KAAa;IAC5C,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO;QAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,IA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,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The registry's claims, dual-written (K-68 step 3b, part 2; rfc/tenant-scale.md §7.3).
3
+ *
4
+ * The directory decides every uniqueness today (a tenant id, a slug, a hostname) and keeps deciding
5
+ * it until 3e. After the split the REGISTRY holds those keys, claimed through the intent-first
6
+ * crossing (`@substrat-run/kernel`'s `directory-crossing`). So the dual-write copies the claims too,
7
+ * through that same helper, in the order §7.3 gives: the tenant's object, which decides, records the
8
+ * crossing in the same transaction as the row that makes it; host code then claims and confirms in
9
+ * the registry, and the object settles.
10
+ *
11
+ * What makes a claim, in a TENANT object (the registry's own copy of a row makes none):
12
+ * - a `tenants` row the object did not hold: `tenant-id` and `tenant-slug` claims. A slug is never
13
+ * changed (no directory path updates it), so the slug claim's id is fixed per tenant;
14
+ * - a `tenants` row moving to `reaped` (or arriving reaped): release the slug, tombstone the id, so an
15
+ * id is never reused (§7.3);
16
+ * - a `hostnames` row the object did not hold: a `hostname` claim, its id unique per binding;
17
+ * - a `hostnames` row deleted: release that binding's claim.
18
+ *
19
+ * A release is recorded in `directory_mirror_releases` beside the row that causes it, and dropped
20
+ * only once the registry released it, or once nothing was claimed under its id (its crossing failed,
21
+ * or was settled and the claim is gone).
22
+ *
23
+ * A release of a key that must become FREE (a hostname, a slug) also settles the crossing it releases
24
+ * `failed`, in the same transaction, if that crossing is still open. Otherwise an open crossing whose
25
+ * claim reached the registry before it was marked `claimed` could be released and then run again:
26
+ * it would find no claim, claim afresh and confirm it, and the registry would hold a key for good
27
+ * that its tenant no longer has. Settled, it never claims again; a claim a crashed runner left is
28
+ * removed by the release, or, if only leased, lapses with its lease. A TOMBSTONE release (a reaped
29
+ * tenant's id) leaves its crossing open on purpose: the crossing may still make the claim the
30
+ * tombstone needs, and a claim made after the tombstone is refused by it.
31
+ *
32
+ * Because the directory already decided, a claim the registry refuses is a difference, not a
33
+ * decision: the crossing settles `failed` with the refusal, the row is applied regardless, and 3d's
34
+ * comparison reports it. The usual cause is a hostname moved between tenants whose release had not
35
+ * reached the registry yet; the flush runs every release before any claim to make that rare.
36
+ */
37
+ import { type ClaimNamespace, type SwitchSql } from '@substrat-run/kernel';
38
+ import type { MirrorChange, MirrorValue } from './directory-mirror.js';
39
+ export declare const MIRROR_CLAIMS_DDL: string[];
40
+ /** How much open claim work one apply hands back to the sender. */
41
+ export declare const MIRROR_CLAIM_WORK_MAX = 20;
42
+ export interface MirrorRelease {
43
+ namespace: ClaimNamespace;
44
+ key: string;
45
+ claimId: string;
46
+ tombstone: boolean;
47
+ }
48
+ /** An object's open claim work, handed back with every apply so a later send retries it. */
49
+ export interface MirrorClaimWork {
50
+ crossings: string[];
51
+ releases: MirrorRelease[];
52
+ }
53
+ export declare const tenantIdCrossingOf: (tenantId: string) => string;
54
+ export declare const tenantSlugCrossingOf: (tenantId: string) => string;
55
+ type Row = Record<string, MirrorValue>;
56
+ /** The tables whose rows make claims, and so need the row before the change. */
57
+ export declare const CLAIMING_TABLES: ReadonlySet<string>;
58
+ /**
59
+ * Record the claim work one applied change makes, inside the transaction that applied it. `before`
60
+ * is the object's row before the change, `change.row` after it (null for a delete).
61
+ */
62
+ export declare function recordMirrorClaims(target: {
63
+ sql: SqlStorage;
64
+ kernelSql: SwitchSql;
65
+ owner: string;
66
+ nowMs: number;
67
+ }, change: MirrorChange, before: Row | null, version: number): void;
68
+ /** The object's open claim work, bounded: crossings not yet settled, releases not yet done. */
69
+ export declare function mirrorClaimWork(sql: SqlStorage, kernelSql: SwitchSql, owner: string): MirrorClaimWork;
70
+ /**
71
+ * After the registry answered a release: drop it once it was released, or once nothing will ever be
72
+ * claimed under its id (its crossing is settled, or was never recorded). Kept while its crossing is
73
+ * open, so the claim that crossing is about to make is still released. True when it was dropped.
74
+ */
75
+ export declare function settleMirrorReleaseIn(sql: SqlStorage, kernelSql: SwitchSql, owner: string, release: MirrorRelease, released: boolean): boolean;
76
+ export {};
77
+ //# sourceMappingURL=directory-mirror-claims.d.ts.map
@@ -0,0 +1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AAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,CASrG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAS9I"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The registry's claims, dual-written (K-68 step 3b, part 2; rfc/tenant-scale.md §7.3).
3
+ *
4
+ * The directory decides every uniqueness today (a tenant id, a slug, a hostname) and keeps deciding
5
+ * it until 3e. After the split the REGISTRY holds those keys, claimed through the intent-first
6
+ * crossing (`@substrat-run/kernel`'s `directory-crossing`). So the dual-write copies the claims too,
7
+ * through that same helper, in the order §7.3 gives: the tenant's object, which decides, records the
8
+ * crossing in the same transaction as the row that makes it; host code then claims and confirms in
9
+ * the registry, and the object settles.
10
+ *
11
+ * What makes a claim, in a TENANT object (the registry's own copy of a row makes none):
12
+ * - a `tenants` row the object did not hold: `tenant-id` and `tenant-slug` claims. A slug is never
13
+ * changed (no directory path updates it), so the slug claim's id is fixed per tenant;
14
+ * - a `tenants` row moving to `reaped` (or arriving reaped): release the slug, tombstone the id, so an
15
+ * id is never reused (§7.3);
16
+ * - a `hostnames` row the object did not hold: a `hostname` claim, its id unique per binding;
17
+ * - a `hostnames` row deleted: release that binding's claim.
18
+ *
19
+ * A release is recorded in `directory_mirror_releases` beside the row that causes it, and dropped
20
+ * only once the registry released it, or once nothing was claimed under its id (its crossing failed,
21
+ * or was settled and the claim is gone).
22
+ *
23
+ * A release of a key that must become FREE (a hostname, a slug) also settles the crossing it releases
24
+ * `failed`, in the same transaction, if that crossing is still open. Otherwise an open crossing whose
25
+ * claim reached the registry before it was marked `claimed` could be released and then run again:
26
+ * it would find no claim, claim afresh and confirm it, and the registry would hold a key for good
27
+ * that its tenant no longer has. Settled, it never claims again; a claim a crashed runner left is
28
+ * removed by the release, or, if only leased, lapses with its lease. A TOMBSTONE release (a reaped
29
+ * tenant's id) leaves its crossing open on purpose: the crossing may still make the claim the
30
+ * tombstone needs, and a claim made after the tombstone is refused by it.
31
+ *
32
+ * Because the directory already decided, a claim the registry refuses is a difference, not a
33
+ * decision: the crossing settles `failed` with the refusal, the row is applied regardless, and 3d's
34
+ * comparison reports it. The usual cause is a hostname moved between tenants whose release had not
35
+ * reached the registry yet; the flush runs every release before any claim to make that rare.
36
+ */
37
+ import { crossingIn, openCrossingsIn, recordCrossingIn, settleCrossingIn, } from '@substrat-run/kernel';
38
+ export const MIRROR_CLAIMS_DDL = [
39
+ `CREATE TABLE IF NOT EXISTS directory_mirror_releases (
40
+ namespace TEXT NOT NULL,
41
+ claim_key TEXT NOT NULL,
42
+ claim_id TEXT NOT NULL,
43
+ tombstone INTEGER NOT NULL,
44
+ recorded_at TEXT NOT NULL,
45
+ PRIMARY KEY (namespace, claim_key, claim_id)
46
+ ) WITHOUT ROWID`,
47
+ ];
48
+ /** How much open claim work one apply hands back to the sender. */
49
+ export const MIRROR_CLAIM_WORK_MAX = 20;
50
+ export const tenantIdCrossingOf = (tenantId) => `mirror:tenant-id:${tenantId}`;
51
+ export const tenantSlugCrossingOf = (tenantId) => `mirror:tenant-slug:${tenantId}`;
52
+ const hostnameCrossingOf = (hostname, version) => `mirror:hostname:${hostname}:${version}`;
53
+ function recordRelease(target, release, at) {
54
+ // A key that must become free: its crossing may not claim it once this release exists (header).
55
+ if (!release.tombstone) {
56
+ settleCrossingIn(target.kernelSql, target.owner, release.claimId, { state: 'failed', outcome: 'released before it settled', nowMs: target.nowMs });
57
+ }
58
+ target.sql.exec(`INSERT OR IGNORE INTO directory_mirror_releases (namespace, claim_key, claim_id, tombstone, recorded_at) VALUES (?, ?, ?, ?, ?)`, release.namespace, release.key, release.claimId, release.tombstone ? 1 : 0, at);
59
+ }
60
+ /** The tables whose rows make claims, and so need the row before the change. */
61
+ export const CLAIMING_TABLES = new Set(['tenants', 'hostnames']);
62
+ /**
63
+ * Record the claim work one applied change makes, inside the transaction that applied it. `before`
64
+ * is the object's row before the change, `change.row` after it (null for a delete).
65
+ */
66
+ export function recordMirrorClaims(target, change, before, version) {
67
+ const after = change.row;
68
+ const at = new Date(target.nowMs).toISOString();
69
+ const record = (input) => recordCrossingIn(target.kernelSql, target.owner, input);
70
+ if (change.table === 'tenants') {
71
+ const tenantId = String((after ?? before)?.['tenant_id'] ?? '');
72
+ if (!tenantId)
73
+ return;
74
+ const slug = String((after ?? before)?.['slug'] ?? '');
75
+ if (after && !before) {
76
+ record({ crossingId: tenantIdCrossingOf(tenantId), kind: 'mirror-tenant-create', namespace: 'tenant-id', key: tenantId, holder: tenantId, jurisdiction: 'global', nowMs: target.nowMs });
77
+ record({ crossingId: tenantSlugCrossingOf(tenantId), kind: 'mirror-tenant-create', namespace: 'tenant-slug', key: slug, holder: tenantId, nowMs: target.nowMs });
78
+ }
79
+ const reapedNow = after?.['status'] === 'reaped' && before?.['status'] !== 'reaped';
80
+ if (reapedNow || (!after && before)) {
81
+ recordRelease(target, { namespace: 'tenant-slug', key: slug, claimId: tenantSlugCrossingOf(tenantId), tombstone: false }, at);
82
+ recordRelease(target, { namespace: 'tenant-id', key: tenantId, claimId: tenantIdCrossingOf(tenantId), tombstone: true }, at);
83
+ }
84
+ return;
85
+ }
86
+ if (change.table === 'hostnames') {
87
+ if (after && !before) {
88
+ const hostname = String(after['hostname']);
89
+ record({
90
+ crossingId: hostnameCrossingOf(hostname, version), kind: 'mirror-hostname-bind', namespace: 'hostname', key: hostname,
91
+ holder: String(after['tenant_id']), scopeId: after['scope_id'] ?? null, nowMs: target.nowMs,
92
+ });
93
+ }
94
+ else if (!after && before) {
95
+ const hostname = String(before['hostname']);
96
+ const held = target.sql
97
+ .exec(`SELECT crossing_id FROM _substrat_directory_crossings WHERE owner = ? AND namespace = 'hostname' AND claim_key = ?
98
+ ORDER BY created_at DESC, crossing_id DESC LIMIT 1`, target.owner, hostname)
99
+ .toArray()[0];
100
+ if (held)
101
+ recordRelease(target, { namespace: 'hostname', key: hostname, claimId: held.crossing_id, tombstone: false }, at);
102
+ }
103
+ }
104
+ }
105
+ /** The object's open claim work, bounded: crossings not yet settled, releases not yet done. */
106
+ export function mirrorClaimWork(sql, kernelSql, owner) {
107
+ const crossings = openCrossingsIn(kernelSql, owner, { updatedBefore: '9999-12-31T23:59:59.999Z', limit: MIRROR_CLAIM_WORK_MAX })
108
+ .filter((c) => c.crossingId.startsWith('mirror:'))
109
+ .map((c) => c.crossingId);
110
+ const releases = sql
111
+ .exec(`SELECT namespace, claim_key, claim_id, tombstone FROM directory_mirror_releases ORDER BY recorded_at, claim_id LIMIT ?`, MIRROR_CLAIM_WORK_MAX)
112
+ .toArray()
113
+ .map((r) => ({ namespace: r.namespace, key: r.claim_key, claimId: r.claim_id, tombstone: r.tombstone === 1 }));
114
+ return { crossings, releases };
115
+ }
116
+ /**
117
+ * After the registry answered a release: drop it once it was released, or once nothing will ever be
118
+ * claimed under its id (its crossing is settled, or was never recorded). Kept while its crossing is
119
+ * open, so the claim that crossing is about to make is still released. True when it was dropped.
120
+ */
121
+ export function settleMirrorReleaseIn(sql, kernelSql, owner, release, released) {
122
+ const crossing = crossingIn(kernelSql, owner, release.claimId);
123
+ const open = crossing !== null && (crossing.state === 'intent' || crossing.state === 'claimed');
124
+ if (!released && open)
125
+ return false;
126
+ sql.exec(`DELETE FROM directory_mirror_releases WHERE namespace = ? AND claim_key = ? AND claim_id = ?`, release.namespace, release.key, release.claimId);
127
+ return true;
128
+ }
129
+ //# sourceMappingURL=directory-mirror-claims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-mirror-claims.js","sourceRoot":"","sources":["../src/directory-mirror-claims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EACL,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB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,CAAC;IAC/D,MAAM,IAAI,GAAG,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAChG,IAAI,CAAC,QAAQ,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IACpC,GAAG,CAAC,IAAI,CACN,8FAA8F,EAC9F,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAChD,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,201 @@
1
+ import { type DirectoryObjectKind } from './directory-placement.js';
2
+ import type { MirrorClaimWork } from './directory-mirror-claims.js';
3
+ /** The tables this owns in the directory. Excluded from a dump, kept across a restore. */
4
+ export declare const DIRECTORY_MIRROR_TABLE_GLOB = "directory_mirror_*";
5
+ /** A crafted dump naming one of them is refused (`importDump`). */
6
+ export declare const isDirectoryMirrorTable: (name: string) => boolean;
7
+ /** How soon a failed send is tried again, by the alarm. */
8
+ export declare const MIRROR_RETRY_MS = 10000;
9
+ /** Outbox rows one batch reads, and one flush at most (the rest go on the next kick). */
10
+ export declare const MIRROR_BATCH = 100;
11
+ export declare const MIRROR_FLUSH_MAX_ROWS = 1000;
12
+ type TargetSql = (ref: string) => string;
13
+ export interface MirrorRoute {
14
+ targets: readonly TargetSql[];
15
+ /** Why the route is not the placement's default, for the PR's owner list. */
16
+ note?: string;
17
+ }
18
+ /** The route of a mirrored table, or null for one no object takes a copy of. */
19
+ export declare function mirrorRouteOf(table: string): MirrorRoute | null;
20
+ /** Every table the mirror can copy, in placement order. */
21
+ export declare const MIRRORED_TABLES: readonly string[];
22
+ /** The owner expressions of one row: what the triggers append and what 3d's comparison reads. */
23
+ export declare function mirrorTargetsSql(table: string, ref: string): string[];
24
+ /** The object kind an owner names. */
25
+ export declare const objectKindOfOwner: (owner: string) => DirectoryObjectKind;
26
+ /**
27
+ * The switch as the control plane's environment spells it: unset, empty or `off` mirrors nothing;
28
+ * `all` mirrors every table; otherwise a comma list of `MIRRORED_TABLES`. A name it does not know
29
+ * is refused rather than ignored, so a typo cannot read as "on".
30
+ */
31
+ export declare function parseDirectoryMirror(value: unknown): string[];
32
+ /** A table's key: its declared primary key, in order, or its rowid when it declares none. */
33
+ export declare function mirrorKeyColumns(sql: SqlStorage, table: string): string[];
34
+ /** The triggers one table needs, spelled as `sqlite_master` keeps them (compared text for text). */
35
+ export declare function directoryMirrorTriggerSql(sql: SqlStorage, table: string): {
36
+ name: string;
37
+ sql: string;
38
+ }[];
39
+ /** Switch the mirror off on a directory that had it: its triggers go; its queue and version stay. */
40
+ export declare function uninstallDirectoryMirror(sql: SqlStorage): void;
41
+ /** Take the next version, inside the caller's transaction (a flush batch, a 3c backfill page). */
42
+ export declare function takeMirrorVersion(sql: SqlStorage): number;
43
+ /** A column value as the directory stores it. The directory holds no BLOB column (checked on read). */
44
+ export type MirrorValue = string | number | null;
45
+ /** One key's change, as an object applies it: the row as it stands, or null for a delete. */
46
+ export interface MirrorChange {
47
+ table: string;
48
+ /** The key's values as a JSON array, in the table's key order (`mirrorKeyColumns`). */
49
+ key: string;
50
+ row: Record<string, MirrorValue> | null;
51
+ }
52
+ /** One send: every change carries the batch's version. */
53
+ export interface MirrorBatch {
54
+ version: number;
55
+ changes: MirrorChange[];
56
+ }
57
+ /** What an object did with a batch (`applyMirrorBatch`). */
58
+ export interface MirrorApplyResult {
59
+ applied: number;
60
+ /** Already held at this version or a later one. */
61
+ stale: number;
62
+ /** Refused by the object's schema (a parent not there yet, mostly), kept and retried there. */
63
+ parked: number;
64
+ /** Rows parked earlier that applied this time. */
65
+ healed: number;
66
+ /** Rows the apply wrote in the object, as its cursors counted them. */
67
+ rowsWritten: number;
68
+ /** A tenant object's open claim work (part 2, `directory-mirror-claims.ts`), retried after every send. */
69
+ claims?: MirrorClaimWork;
70
+ }
71
+ /** What one round of claim work did (`MirrorSender.settleClaims`). */
72
+ export interface MirrorClaimReport {
73
+ /** Crossings driven to `done`, and to `failed` (a refusal: a difference for 3d, not a decision). */
74
+ claimed: number;
75
+ refused: number;
76
+ released: number;
77
+ /** Calls that threw; the work stays recorded in its object and is handed back on the next send. */
78
+ errors: number;
79
+ }
80
+ /** How the directory reaches the objects: an RPC stub per owner on Cloudflare. */
81
+ export interface MirrorSender {
82
+ send(owner: string, batch: MirrorBatch): Promise<MirrorApplyResult>;
83
+ /** Drive the claim work the objects handed back: every release, then every crossing, then the releases left. */
84
+ settleClaims?(work: readonly {
85
+ owner: string;
86
+ claims: MirrorClaimWork;
87
+ }[]): Promise<MirrorClaimReport>;
88
+ /** One page of a tenant object's open claim work, asked again until it is empty. */
89
+ claimWork?(owner: string): Promise<MirrorClaimWork>;
90
+ }
91
+ /** How many owners one flush drains claim work for, and how many pages each at most. */
92
+ export declare const MIRROR_CLAIM_OWNERS_PER_FLUSH = 20;
93
+ export declare const MIRROR_CLAIM_PAGES_PER_OWNER = 10;
94
+ export interface MirrorFlush {
95
+ /** Outbox rows read and acknowledged. */
96
+ read: number;
97
+ acked: number;
98
+ /** Changes sent, and what the objects did with them. */
99
+ sent: number;
100
+ applied: number;
101
+ stale: number;
102
+ parked: number;
103
+ healed: number;
104
+ /** Rows the directory had no object for (a tenant-placed row without a tenant). */
105
+ unplaced: number;
106
+ /** The registry claims the batches' objects handed back, driven after each batch. */
107
+ claims: MirrorClaimReport;
108
+ /** Rows written by the flush itself, in the directory (version, acks) and in the objects. */
109
+ rowsWrittenDirectory: number;
110
+ rowsWrittenObjects: number;
111
+ /** Stopped because a directory method was running; that method's return restarts it. */
112
+ deferred: boolean;
113
+ /** Owners whose send failed this flush; their rows went to the back of the outbox. */
114
+ failed: string[];
115
+ }
116
+ export interface MirrorStatus {
117
+ enabled: true;
118
+ tables: {
119
+ table: string;
120
+ since: string;
121
+ }[];
122
+ version: number;
123
+ restoredAt: string | null;
124
+ queued: number;
125
+ oldestQueuedId: number | null;
126
+ /** Owners whose registry claim work is not drained yet. */
127
+ claimsDue: number;
128
+ }
129
+ export interface DirectoryMirrorOptions {
130
+ sql: SqlStorage;
131
+ /** The mirrored tables (`parseDirectoryMirror`), non-empty. */
132
+ tables: readonly string[];
133
+ sender: MirrorSender;
134
+ transaction: <T>(fn: () => T) => T;
135
+ /** No directory method is running, so a read sees only committed writes. */
136
+ quiet: () => boolean;
137
+ /** Arm the directory's alarm no later than `at` (an earlier one is kept). */
138
+ armRetry: (at: number) => Promise<void>;
139
+ now?: () => number;
140
+ }
141
+ /** The directory's half, one per `ControlPlaneDO` instance while the switch is on. */
142
+ export declare class DirectoryMirror {
143
+ private readonly options;
144
+ private readonly sql;
145
+ private readonly keys;
146
+ private flushing;
147
+ private again;
148
+ private retryAfter;
149
+ /** The last flush's account, for status and tests. */
150
+ last: MirrorFlush | null;
151
+ constructor(options: DirectoryMirrorOptions);
152
+ private now;
153
+ /**
154
+ * Create the tables and hold the triggers to the switch, in the caller's transaction: a table
155
+ * switched on gets its triggers and `since = now`, one switched off loses them. Writes nothing
156
+ * when nothing changed. Run on construction and after a restore (whose drops took the triggers).
157
+ */
158
+ install(): {
159
+ enabled: string[];
160
+ disabled: string[];
161
+ };
162
+ /** A restore replaced the directory: every object now differs from it until 3c fills them again. */
163
+ markRestored(): void;
164
+ pending(): boolean;
165
+ status(): MirrorStatus;
166
+ private keyColumns;
167
+ /** The row a key names as it stands, and the owners it is placed in now. */
168
+ private readCurrent;
169
+ /** One batch, read in one transaction: the version, then each key's current row. */
170
+ private readBatch;
171
+ /**
172
+ * Send what the outbox holds, batch by batch, up to `maxRows`. Throws once every send it started
173
+ * has settled when any was refused: what an object confirmed is acknowledged, the rest has moved
174
+ * to the back of the outbox.
175
+ */
176
+ flush(maxRows?: number): Promise<MirrorFlush>;
177
+ /**
178
+ * Drain the registry claim work of the owners recorded due, page by page, until each object reports
179
+ * none. A round that throws, or settles nothing while work is left, is a failure: the owner stays
180
+ * due and the flush throws, so the alarm retries it. A refusal settles its crossing and is progress.
181
+ */
182
+ private drainClaims;
183
+ /**
184
+ * Called when the directory's outermost method returns. One flush at a time: a kick during a
185
+ * flush runs one more round after it. After a failure only the alarm retries (`retry`).
186
+ */
187
+ kick(): void;
188
+ /** The alarm's half: lift the backoff and flush. */
189
+ retry(): void;
190
+ /** Wait until the outbox is drained, or a flush fails (for a caller, and a test, that must see it land). */
191
+ settle(): Promise<MirrorFlush | null>;
192
+ private own;
193
+ }
194
+ /**
195
+ * The directory's mirror as its environment sets it: null (and every mirror trigger dropped) when
196
+ * `DIRECTORY_MIRROR` is off, refused, or the objects are not bound; otherwise installed and ready to
197
+ * kick. Called once, from `ControlPlaneDO`'s constructor.
198
+ */
199
+ export declare function directoryMirrorFor(env: unknown, sender: MirrorSender | null, options: Omit<DirectoryMirrorOptions, 'tables' | 'sender'>): DirectoryMirror | null;
200
+ export {};
201
+ //# sourceMappingURL=directory-mirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-mirror.d.ts","sourceRoot":"","sources":["../src/directory-mirror.ts"],"names":[],"mappings":"AAoDA,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,0FAA0F;AAC1F,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,SAAU,MAAM,KAAG,OAA6D,CAAC;AAEpH,2DAA2D;AAC3D,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,yFAAyF;AACzF,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAO3C,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAiBzC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,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