@honua/app-platform 0.1.11-beta.0 → 0.1.13

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 (236) hide show
  1. package/columnar/apache-arrow.d.ts +17 -0
  2. package/columnar/apache-arrow.d.ts.map +1 -0
  3. package/columnar/apache-arrow.js +1036 -0
  4. package/columnar/batch-cache-conformance.d.ts +66 -0
  5. package/columnar/batch-cache-conformance.d.ts.map +1 -0
  6. package/columnar/batch-cache-conformance.js +317 -0
  7. package/columnar/batch-cache-indexeddb.d.ts +31 -0
  8. package/columnar/batch-cache-indexeddb.d.ts.map +1 -0
  9. package/columnar/batch-cache-indexeddb.js +148 -0
  10. package/columnar/batch-cache.d.ts +298 -0
  11. package/columnar/batch-cache.d.ts.map +1 -0
  12. package/columnar/batch-cache.js +757 -0
  13. package/columnar/geoarrow-aggregate.d.ts +178 -0
  14. package/columnar/geoarrow-aggregate.d.ts.map +1 -0
  15. package/columnar/geoarrow-aggregate.js +976 -0
  16. package/columnar/geoarrow-patch.d.ts +382 -0
  17. package/columnar/geoarrow-patch.d.ts.map +1 -0
  18. package/columnar/geoarrow-patch.js +1656 -0
  19. package/columnar/geoarrow-reproject.d.ts +22 -0
  20. package/columnar/geoarrow-reproject.d.ts.map +1 -0
  21. package/columnar/geoarrow-reproject.js +119 -0
  22. package/columnar/geoarrow-serialization.d.ts +68 -0
  23. package/columnar/geoarrow-serialization.d.ts.map +1 -0
  24. package/columnar/geoarrow-serialization.js +331 -0
  25. package/columnar/geoarrow-types.d.ts +271 -0
  26. package/columnar/geoarrow-types.d.ts.map +1 -0
  27. package/columnar/geoarrow-types.js +15 -0
  28. package/columnar/geoarrow.d.ts +52 -0
  29. package/columnar/geoarrow.d.ts.map +1 -0
  30. package/columnar/geoarrow.js +1469 -0
  31. package/columnar/index.d.ts +43 -0
  32. package/columnar/index.d.ts.map +1 -0
  33. package/columnar/index.js +29 -0
  34. package/columnar/operators.d.ts +70 -0
  35. package/columnar/operators.d.ts.map +1 -0
  36. package/columnar/operators.js +307 -0
  37. package/columnar/result.d.ts +369 -0
  38. package/columnar/result.d.ts.map +1 -0
  39. package/columnar/result.js +815 -0
  40. package/columnar/telemetry.d.ts +152 -0
  41. package/columnar/telemetry.d.ts.map +1 -0
  42. package/columnar/telemetry.js +265 -0
  43. package/columnar/transfer.d.ts +28 -0
  44. package/columnar/transfer.d.ts.map +1 -0
  45. package/columnar/transfer.js +669 -0
  46. package/columnar/types.d.ts +175 -0
  47. package/columnar/types.d.ts.map +1 -0
  48. package/columnar/types.js +22 -0
  49. package/columnar/worker.d.ts +157 -0
  50. package/columnar/worker.d.ts.map +1 -0
  51. package/columnar/worker.js +1059 -0
  52. package/contract/pmtiles.d.ts +6 -5
  53. package/contract/pmtiles.d.ts.map +1 -1
  54. package/contract/pmtiles.js +30 -5
  55. package/control-plane/generated/admin-operations.d.ts +3 -3
  56. package/control-plane/generated/admin-operations.d.ts.map +1 -1
  57. package/control-plane/generated/admin-operations.js +3 -3
  58. package/controls/catalog.d.ts.map +1 -1
  59. package/controls/catalog.js +110 -0
  60. package/controls/index.d.ts +1 -1
  61. package/controls/index.js +1 -1
  62. package/controls/types.d.ts +1 -1
  63. package/controls/types.js +1 -1
  64. package/core/client.d.ts.map +1 -1
  65. package/core/client.js +87 -19
  66. package/core/deprecation-notice.d.ts +28 -0
  67. package/core/deprecation-notice.d.ts.map +1 -0
  68. package/core/deprecation-notice.js +22 -0
  69. package/core/esri-geojson.d.ts.map +1 -1
  70. package/core/esri-geojson.js +10 -6
  71. package/core/optional-grpc-peer.d.ts +15 -0
  72. package/core/optional-grpc-peer.d.ts.map +1 -0
  73. package/core/optional-grpc-peer.js +60 -0
  74. package/esri-compat/basemap-gallery.d.ts +2 -0
  75. package/esri-compat/basemap-gallery.d.ts.map +1 -1
  76. package/esri-compat/basemap-gallery.js +12 -0
  77. package/esri-compat/basemap.d.ts +4 -0
  78. package/esri-compat/basemap.d.ts.map +1 -1
  79. package/esri-compat/basemap.js +70 -0
  80. package/esri-compat/bookmarks.d.ts +2 -0
  81. package/esri-compat/bookmarks.d.ts.map +1 -1
  82. package/esri-compat/bookmarks.js +12 -0
  83. package/esri-compat/controls.d.ts +18 -0
  84. package/esri-compat/controls.d.ts.map +1 -1
  85. package/esri-compat/controls.js +120 -57
  86. package/esri-compat/directions.d.ts +4 -0
  87. package/esri-compat/directions.d.ts.map +1 -1
  88. package/esri-compat/directions.js +30 -20
  89. package/esri-compat/editor.d.ts +4 -0
  90. package/esri-compat/editor.d.ts.map +1 -1
  91. package/esri-compat/editor.js +16 -0
  92. package/esri-compat/esri-config.d.ts +2 -1
  93. package/esri-compat/esri-config.d.ts.map +1 -1
  94. package/esri-compat/feature-effect.d.ts +23 -0
  95. package/esri-compat/feature-effect.d.ts.map +1 -0
  96. package/esri-compat/feature-effect.js +12 -0
  97. package/esri-compat/feature-form.d.ts +6 -0
  98. package/esri-compat/feature-form.d.ts.map +1 -1
  99. package/esri-compat/feature-form.js +63 -0
  100. package/esri-compat/feature-layer.d.ts +21 -2
  101. package/esri-compat/feature-layer.d.ts.map +1 -1
  102. package/esri-compat/feature-layer.js +172 -1
  103. package/esri-compat/feature-table.d.ts +5 -0
  104. package/esri-compat/feature-table.d.ts.map +1 -1
  105. package/esri-compat/feature-table.js +23 -0
  106. package/esri-compat/identity-manager.d.ts +1 -1
  107. package/esri-compat/identity-manager.js +1 -1
  108. package/esri-compat/legend.d.ts +2 -0
  109. package/esri-compat/legend.d.ts.map +1 -1
  110. package/esri-compat/legend.js +98 -0
  111. package/esri-compat/locator.d.ts +1 -1
  112. package/esri-compat/locator.js +1 -1
  113. package/esri-compat/map-view-mount.d.ts +1 -0
  114. package/esri-compat/map-view-mount.d.ts.map +1 -1
  115. package/esri-compat/map-view-mount.js +46 -25
  116. package/esri-compat/map-view.d.ts +13 -0
  117. package/esri-compat/map-view.d.ts.map +1 -1
  118. package/esri-compat/map-view.js +94 -8
  119. package/esri-compat/map.d.ts +5 -1
  120. package/esri-compat/map.d.ts.map +1 -1
  121. package/esri-compat/map.js +10 -0
  122. package/esri-compat/measurement.d.ts +2 -0
  123. package/esri-compat/measurement.d.ts.map +1 -1
  124. package/esri-compat/measurement.js +14 -0
  125. package/esri-compat/point.d.ts +7 -0
  126. package/esri-compat/point.d.ts.map +1 -1
  127. package/esri-compat/point.js +33 -3
  128. package/esri-compat/popup.d.ts +2 -0
  129. package/esri-compat/popup.d.ts.map +1 -1
  130. package/esri-compat/popup.js +12 -0
  131. package/esri-compat/portal.d.ts +1 -1
  132. package/esri-compat/portal.js +1 -1
  133. package/esri-compat/print.d.ts +3 -0
  134. package/esri-compat/print.d.ts.map +1 -1
  135. package/esri-compat/print.js +15 -0
  136. package/esri-compat/search.d.ts +4 -0
  137. package/esri-compat/search.d.ts.map +1 -1
  138. package/esri-compat/search.js +25 -28
  139. package/esri-compat/sketch.d.ts +2 -0
  140. package/esri-compat/sketch.d.ts.map +1 -1
  141. package/esri-compat/sketch.js +12 -0
  142. package/esri-compat/widget-host.d.ts +46 -17
  143. package/esri-compat/widget-host.d.ts.map +1 -1
  144. package/esri-compat/widget-host.js +84 -20
  145. package/esri-compat/widget-shell-hosts.d.ts +61 -0
  146. package/esri-compat/widget-shell-hosts.d.ts.map +1 -0
  147. package/esri-compat/widget-shell-hosts.js +76 -0
  148. package/kernel/renderer.d.ts +82 -0
  149. package/kernel/renderer.js +1 -0
  150. package/offline/conflict-resolution.d.ts +183 -0
  151. package/offline/conflict-resolution.d.ts.map +1 -0
  152. package/offline/conflict-resolution.js +286 -0
  153. package/offline/credential-screen.d.ts +34 -0
  154. package/offline/credential-screen.d.ts.map +1 -0
  155. package/offline/credential-screen.js +78 -0
  156. package/offline/digest.d.ts +15 -0
  157. package/offline/digest.d.ts.map +1 -0
  158. package/offline/digest.js +58 -0
  159. package/offline/edit-queue.d.ts +403 -0
  160. package/offline/edit-queue.d.ts.map +1 -0
  161. package/offline/edit-queue.js +1807 -0
  162. package/offline/edit-replay.d.ts +116 -0
  163. package/offline/edit-replay.d.ts.map +1 -0
  164. package/offline/edit-replay.js +392 -0
  165. package/offline/fetch-handler.d.ts +12 -0
  166. package/offline/fetch-handler.d.ts.map +1 -0
  167. package/offline/fetch-handler.js +65 -0
  168. package/offline/index.d.ts +52 -0
  169. package/offline/index.d.ts.map +1 -0
  170. package/offline/index.js +34 -0
  171. package/offline/indexeddb.d.ts +135 -0
  172. package/offline/indexeddb.d.ts.map +1 -0
  173. package/offline/indexeddb.js +888 -0
  174. package/offline/memory-store.d.ts +17 -0
  175. package/offline/memory-store.d.ts.map +1 -0
  176. package/offline/memory-store.js +183 -0
  177. package/offline/quota.d.ts +161 -0
  178. package/offline/quota.d.ts.map +1 -0
  179. package/offline/quota.js +370 -0
  180. package/offline/read-gate.d.ts +175 -0
  181. package/offline/read-gate.d.ts.map +1 -0
  182. package/offline/read-gate.js +252 -0
  183. package/offline/read-resource.d.ts +99 -0
  184. package/offline/read-resource.d.ts.map +1 -0
  185. package/offline/read-resource.js +156 -0
  186. package/offline/read.d.ts +50 -0
  187. package/offline/read.d.ts.map +1 -0
  188. package/offline/read.js +65 -0
  189. package/offline/region.d.ts +29 -0
  190. package/offline/region.d.ts.map +1 -0
  191. package/offline/region.js +1007 -0
  192. package/offline/replay-conflict.d.ts +183 -0
  193. package/offline/replay-conflict.d.ts.map +1 -0
  194. package/offline/replay-conflict.js +482 -0
  195. package/offline/selection.d.ts +140 -0
  196. package/offline/selection.d.ts.map +1 -0
  197. package/offline/selection.js +391 -0
  198. package/offline/snapshot.d.ts +132 -0
  199. package/offline/snapshot.d.ts.map +1 -0
  200. package/offline/snapshot.js +312 -0
  201. package/offline/status.d.ts +136 -0
  202. package/offline/status.d.ts.map +1 -0
  203. package/offline/status.js +479 -0
  204. package/offline/store-conformance.d.ts +48 -0
  205. package/offline/store-conformance.d.ts.map +1 -0
  206. package/offline/store-conformance.js +233 -0
  207. package/offline/tile-protocol.d.ts +81 -0
  208. package/offline/tile-protocol.d.ts.map +1 -0
  209. package/offline/tile-protocol.js +119 -0
  210. package/offline/types.d.ts +349 -0
  211. package/offline/types.d.ts.map +1 -0
  212. package/offline/types.js +75 -0
  213. package/package.json +14 -2
  214. package/scene-workspace/index.d.ts +2 -2
  215. package/scene-workspace/index.d.ts.map +1 -1
  216. package/scene-workspace/index.js +1 -1
  217. package/scene-workspace/scene-discovery.d.ts +111 -91
  218. package/scene-workspace/scene-discovery.d.ts.map +1 -1
  219. package/scene-workspace/scene-discovery.js +340 -92
  220. package/scene-workspace/scene-view.d.ts +6 -6
  221. package/scene-workspace/scene-view.d.ts.map +1 -1
  222. package/scene-workspace/scene-view.js +32 -6
  223. package/web-components/elements.d.ts +34 -0
  224. package/web-components/elements.d.ts.map +1 -1
  225. package/web-components/elements.js +82 -8
  226. package/web-components/index.d.ts +2 -0
  227. package/web-components/index.d.ts.map +1 -1
  228. package/web-components/index.js +3 -1
  229. package/web-components/map-chrome.d.ts +103 -0
  230. package/web-components/map-chrome.d.ts.map +1 -0
  231. package/web-components/map-chrome.js +325 -0
  232. package/web-components/widget-shell.d.ts +68 -0
  233. package/web-components/widget-shell.d.ts.map +1 -0
  234. package/web-components/widget-shell.js +224 -0
  235. package/widget-capabilities.d.ts +67 -0
  236. package/widget-capabilities.js +152 -0
@@ -0,0 +1,298 @@
1
+ /**
2
+ * Bounded persistent cache for serialized GeoArrow batches (issue #940).
3
+ *
4
+ * Epic #394 requires batch identity to bind "plan hash, source/schema version,
5
+ * authorization scope, ordering, and freshness". `ColumnarBatchIdentityV1`
6
+ * carried that information but nothing turned it into a storage key, so a cache
7
+ * built on top of the serialization envelope would have been free to key a
8
+ * batch by source id alone — a cross-tenant read shape. This module lands the
9
+ * key contract and the store together, with the same discipline the offline
10
+ * region store and the realtime checkpoint store already use:
11
+ *
12
+ * 1. **Identity-bound keys.** {@link columnarBatchCacheKey} digests the source,
13
+ * plan, schema, ordering, and freshness *validators* together with a digest
14
+ * of the authorization scope. The raw scope never appears in the key or in a
15
+ * persisted record, and a change to any keyed component addresses a
16
+ * different entry rather than reusing this one.
17
+ * 2. **Versioned envelope with a migration ladder.** Payloads are written
18
+ * through `serializeGeoArrowBatch` and read through
19
+ * `deserializeGeoArrowBatch`, so an entry written by an older layout is
20
+ * migrated forward on read and an unreadable one is discarded explicitly —
21
+ * never misread. The record additionally stamps its own
22
+ * `honua.columnar-batch-cache/…` format; a record with a foreign format is
23
+ * treated as corrupt and deleted.
24
+ * 3. **Verified before served.** Every read recomputes the SHA-256 of the
25
+ * stored envelope bytes and compares it to the digest recorded at write
26
+ * time. A mismatch is a miss *and* a delete; a batch is never returned from
27
+ * bytes that were not proven intact.
28
+ * 4. **Bounded with deterministic eviction.** A byte quota and a record cap are
29
+ * both enforced by {@link planColumnarBatchCacheAdmission}, a pure function
30
+ * that evicts oldest-first with a code-unit tie-break, and the write plus its
31
+ * evictions are handed to the backend as one atomic operation.
32
+ *
33
+ * **Persistence is opt-in and the default is no cache.** Nothing in the SDK
34
+ * constructs one of these: a batch is cached only when an application creates a
35
+ * store, chooses a backend, and calls {@link ColumnarBatchCacheHandle.write}.
36
+ *
37
+ * The store is backend-agnostic — it holds no IndexedDB, filesystem, or Node
38
+ * reference — so it runs unchanged in a worker, on a server, and in a browser.
39
+ * `batch-cache-indexeddb.ts` supplies the browser backend, and
40
+ * {@link createMemoryColumnarBatchCacheStorage} supplies an in-process one with
41
+ * identical semantics.
42
+ *
43
+ * @experimental
44
+ */
45
+ import type { GeoArrowSerializationMetrics, GeoArrowSerializationOptions } from "./geoarrow-types.js";
46
+ import { type ColumnarTelemetry } from "./telemetry.js";
47
+ import type { ColumnarBatchIdentityV1, ColumnarBatchV1 } from "./types.js";
48
+ /**
49
+ * Versioned format string stamped on every persisted record. A record whose
50
+ * format differs is corrupt to this build and is discarded on read, so a future
51
+ * record layout can never be misinterpreted as this one.
52
+ */
53
+ export declare const HONUA_COLUMNAR_BATCH_CACHE_FORMAT: "honua.columnar-batch-cache/1.0";
54
+ /** Default byte quota across stored envelopes. Callers should size it explicitly. */
55
+ export declare const DEFAULT_COLUMNAR_BATCH_CACHE_QUOTA_BYTES: number;
56
+ /** Absolute ceiling on `quotaBytes`. Callers may tighten it, never raise it. */
57
+ export declare const MAX_COLUMNAR_BATCH_CACHE_QUOTA_BYTES: number;
58
+ /** Default cap on retained entries; the oldest is evicted first. */
59
+ export declare const DEFAULT_COLUMNAR_BATCH_CACHE_MAX_RECORDS = 64;
60
+ /** Absolute ceiling on `maxRecords`. */
61
+ export declare const MAX_COLUMNAR_BATCH_CACHE_MAX_RECORDS = 4096;
62
+ /**
63
+ * Default maximum entry age. A batch older than this is reported stale even
64
+ * when its identity still matches, because a source may change without changing
65
+ * a validator the client can see.
66
+ */
67
+ export declare const DEFAULT_COLUMNAR_BATCH_CACHE_MAX_AGE_MS: number;
68
+ /** Absolute ceiling on `maxAgeMs`. */
69
+ export declare const MAX_COLUMNAR_BATCH_CACHE_MAX_AGE_MS: number;
70
+ /** Freshness the producer observed, recorded so a read can refuse expired data. */
71
+ export interface ColumnarBatchCacheFreshnessV1 {
72
+ readonly observedAt: string;
73
+ readonly staleAfter?: string;
74
+ readonly validator?: string;
75
+ readonly generation?: string;
76
+ }
77
+ /**
78
+ * One persisted cache record. Metadata only: the serialized envelope travels
79
+ * beside it so a backend can enumerate and evict without loading payloads.
80
+ *
81
+ * `observedAt` is when this store wrote the record and drives eviction order;
82
+ * `freshness.observedAt` is when the producer observed the source and drives
83
+ * expiry.
84
+ */
85
+ export interface ColumnarBatchCacheRecordV1 {
86
+ readonly key: `sha256:${string}`;
87
+ readonly format: typeof HONUA_COLUMNAR_BATCH_CACHE_FORMAT;
88
+ /** Envelope layout the payload was written at. */
89
+ readonly envelopeVersion: string;
90
+ readonly sourceId: string;
91
+ readonly sourceVersion: string;
92
+ readonly schemaVersion: string;
93
+ readonly planId: string;
94
+ /** Digest of the identity's authorization scope, never the scope itself. */
95
+ readonly authorizationScopeDigest: `sha256:${string}`;
96
+ /** Digest of the ordering contract the batch was produced under. */
97
+ readonly orderingDigest: `sha256:${string}`;
98
+ readonly freshness: ColumnarBatchCacheFreshnessV1;
99
+ readonly rowCount: number;
100
+ readonly byteLength: number;
101
+ /** SHA-256 over the stored envelope bytes, verified on every read. */
102
+ readonly integrity: `sha256:${string}`;
103
+ readonly observedAt: string;
104
+ }
105
+ /** A record plus the envelope bytes it accounts for. */
106
+ export interface ColumnarBatchCacheEntryV1 {
107
+ readonly record: ColumnarBatchCacheRecordV1;
108
+ readonly envelope: Uint8Array;
109
+ }
110
+ /**
111
+ * Storage primitives the key, screening, integrity, freshness, and eviction
112
+ * logic is built on.
113
+ *
114
+ * Reads may return anything at all — every value is revalidated before it can
115
+ * become a batch — and every method may reject, which degrades to a miss or a
116
+ * refusal rather than an exception in a caller's data path. `write` must apply
117
+ * the entry and its evictions atomically: a partial application would leave the
118
+ * store over quota with no record of why.
119
+ */
120
+ export interface ColumnarBatchCacheStorage {
121
+ /** Metadata for every stored entry, without loading payload bytes. */
122
+ summaries(): Promise<readonly unknown[]>;
123
+ /** One entry, or `undefined`. Returned bytes must be caller-owned. */
124
+ read(key: string): Promise<unknown>;
125
+ /** Atomically write `entry` and delete every key in `evictKeys`. */
126
+ write(entry: ColumnarBatchCacheEntryV1, evictKeys: readonly string[]): Promise<void>;
127
+ remove(key: string): Promise<void>;
128
+ clear(): Promise<void>;
129
+ /** Release any retained connection or buffer. Optional for simple backends. */
130
+ dispose?(): void;
131
+ }
132
+ /** Why a read did not return a batch. */
133
+ export type ColumnarBatchCacheMissReason = "absent" | "aborted" | "disposed" | "corrupt-record" | "foreign-format" | "identity-mismatch" | "authorization-scope-mismatch" | "integrity-mismatch" | "digest-unavailable" | "unsupported-serialization" | "storage-failed";
134
+ /** Why a read found a matching entry that must not be served as fresh. */
135
+ export type ColumnarBatchCacheStaleReason = "freshness-expired" | "max-age-exceeded";
136
+ /** Why a write did not persist. */
137
+ export type ColumnarBatchCacheRefusalReason = "aborted" | "disposed" | "invalid-batch" | "credential-screened" | "quota-exceeded" | "quota-pressure" | "serialization-limit-exceeded" | "digest-unavailable" | "storage-failed";
138
+ /** Outcome of {@link ColumnarBatchCacheHandle.read}. */
139
+ export type ColumnarBatchCacheReadV1 = {
140
+ readonly outcome: "hit";
141
+ readonly key: `sha256:${string}`;
142
+ readonly batch: ColumnarBatchV1;
143
+ readonly metrics: GeoArrowSerializationMetrics;
144
+ readonly record: ColumnarBatchCacheRecordV1;
145
+ } | {
146
+ readonly outcome: "stale";
147
+ readonly key: `sha256:${string}`;
148
+ readonly reason: ColumnarBatchCacheStaleReason;
149
+ /** Kept so the caller can revalidate instead of refetching blind. */
150
+ readonly record: ColumnarBatchCacheRecordV1;
151
+ } | {
152
+ readonly outcome: "miss";
153
+ readonly key: `sha256:${string}`;
154
+ readonly reason: ColumnarBatchCacheMissReason;
155
+ };
156
+ /** Outcome of {@link ColumnarBatchCacheHandle.write}. */
157
+ export type ColumnarBatchCacheWriteV1 = {
158
+ readonly outcome: "stored";
159
+ readonly key: `sha256:${string}`;
160
+ readonly record: ColumnarBatchCacheRecordV1;
161
+ readonly admission: ColumnarBatchCacheAdmissionV1;
162
+ } | {
163
+ readonly outcome: "refused";
164
+ readonly key: `sha256:${string}`;
165
+ readonly reason: ColumnarBatchCacheRefusalReason;
166
+ readonly detail: string;
167
+ };
168
+ /** Deterministic eviction plan for one candidate write. */
169
+ export interface ColumnarBatchCacheAdmissionV1 {
170
+ readonly quotaBytes: number;
171
+ readonly maxRecords: number;
172
+ readonly incomingBytes: number;
173
+ readonly bytesBefore: number;
174
+ /** Bytes reclaimed by replacing an existing entry under the same key. */
175
+ readonly replacedBytes: number;
176
+ readonly evictKeys: readonly string[];
177
+ readonly evictedBytes: number;
178
+ readonly bytesAfter: number;
179
+ readonly recordsAfter: number;
180
+ readonly admitted: boolean;
181
+ }
182
+ /** Structured report of every miss, stale read, refusal, and storage failure. */
183
+ export interface ColumnarBatchCacheDiagnosticV1 {
184
+ readonly kind: "honua.columnar-batch-cache-diagnostic";
185
+ readonly version: 1;
186
+ readonly operation: "read" | "write" | "delete";
187
+ readonly reason: ColumnarBatchCacheMissReason | ColumnarBatchCacheStaleReason | ColumnarBatchCacheRefusalReason;
188
+ /** Key the operation addressed; a digest, never a raw identity. */
189
+ readonly key: `sha256:${string}`;
190
+ readonly detail: string;
191
+ }
192
+ export interface ColumnarBatchCacheOptions {
193
+ /** Byte quota across stored envelopes. @default 67108864 */
194
+ readonly quotaBytes?: number;
195
+ /** Maximum retained entries; the oldest is evicted first. @default 64 */
196
+ readonly maxRecords?: number;
197
+ /** Maximum entry age before a read reports stale. @default 3600000 */
198
+ readonly maxAgeMs?: number;
199
+ readonly now?: () => number;
200
+ /** Bounds applied to every serialize and deserialize this store performs. */
201
+ readonly serialization?: GeoArrowSerializationOptions;
202
+ /** Receives every miss, stale read, refusal, and storage failure. Must not throw. */
203
+ readonly onDiagnostic?: (diagnostic: ColumnarBatchCacheDiagnosticV1) => void;
204
+ /**
205
+ * Optional observer for this store. Off by default, and independent of
206
+ * {@link ColumnarBatchCacheOptions.onDiagnostic}: a caller already using the
207
+ * callback keeps it, and a caller wiring the SDK's telemetry seam sees the
208
+ * same operation and reason discriminants on identity-bound `columnar-cache-read`
209
+ * and `columnar-cache-write` spans.
210
+ */
211
+ readonly telemetry?: ColumnarTelemetry;
212
+ }
213
+ export interface ColumnarBatchCacheReadOptions {
214
+ /** Settles the read as an `aborted` miss without waiting for the backend. */
215
+ readonly signal?: AbortSignal;
216
+ }
217
+ export interface ColumnarBatchCacheWriteOptions {
218
+ /** Settles the write as an `aborted` refusal without waiting for the backend. */
219
+ readonly signal?: AbortSignal;
220
+ }
221
+ /** An identity-keyed batch cache plus the administration a host needs to audit it. */
222
+ export interface ColumnarBatchCacheHandle {
223
+ /** Derive the key this identity addresses, without touching storage. */
224
+ key(identity: ColumnarBatchIdentityV1): Promise<`sha256:${string}`>;
225
+ /**
226
+ * Look one batch up by identity.
227
+ *
228
+ * Only the keyed components matter: the passed `freshness.observedAt` and
229
+ * `freshness.staleAfter` are never compared, because expiry is evaluated
230
+ * against what the *producer* recorded, not against what the reader guessed.
231
+ */
232
+ read(identity: ColumnarBatchIdentityV1, options?: ColumnarBatchCacheReadOptions): Promise<ColumnarBatchCacheReadV1>;
233
+ write(batch: ColumnarBatchV1, options?: ColumnarBatchCacheWriteOptions): Promise<ColumnarBatchCacheWriteV1>;
234
+ /** Drop the entry this identity addresses, if any. */
235
+ delete(identity: ColumnarBatchIdentityV1): Promise<void>;
236
+ /** Every valid persisted record, for enumeration in tests and diagnostics. */
237
+ records(): Promise<readonly ColumnarBatchCacheRecordV1[]>;
238
+ /** Drop every entry, for sign-out and scope teardown. */
239
+ clear(): Promise<void>;
240
+ /** Release retained buffers and connections; later calls settle as `disposed`. */
241
+ dispose(): void;
242
+ }
243
+ /**
244
+ * Deterministic cache key for one batch identity.
245
+ *
246
+ * The key digests source id, source version, schema version, plan id, the
247
+ * ordering contract, the freshness *validators*, and the authorization-scope
248
+ * digest. Two identities that differ in any of those address different entries,
249
+ * and the output is a hex digest, so the raw authorization scope can never
250
+ * appear in it.
251
+ *
252
+ * `freshness.observedAt` and `freshness.staleAfter` are deliberately excluded:
253
+ * they describe *when* a producer observed the source, not *what* was asked
254
+ * for. Keying on them would mint a new entry for every fetch and make the cache
255
+ * unreadable by a caller that does not already hold the answer. Expiry is
256
+ * enforced on read instead, against the record's own recorded freshness.
257
+ */
258
+ export declare function columnarBatchCacheKey(identity: ColumnarBatchIdentityV1): Promise<`sha256:${string}`>;
259
+ /**
260
+ * Digest of the ordering contract a batch was produced under.
261
+ *
262
+ * Recorded beside the batch so a reader can tell "same rows, different sort"
263
+ * apart from "same batch" without trusting the key alone.
264
+ */
265
+ export declare function columnarBatchCacheOrderingDigest(identity: ColumnarBatchIdentityV1): Promise<`sha256:${string}`>;
266
+ /**
267
+ * Plan the evictions that admit `incoming` under `limits`.
268
+ *
269
+ * Pure and deterministic: candidates are ordered by write time and then by key
270
+ * in code-unit order, so two hosts with the same records always evict the same
271
+ * entries. An entry larger than the whole quota is refused outright rather than
272
+ * emptying the store for something that still would not fit.
273
+ */
274
+ export declare function planColumnarBatchCacheAdmission(records: readonly ColumnarBatchCacheRecordV1[], incoming: {
275
+ readonly key: string;
276
+ readonly byteLength: number;
277
+ }, limits: {
278
+ readonly quotaBytes: number;
279
+ readonly maxRecords: number;
280
+ }): ColumnarBatchCacheAdmissionV1;
281
+ /**
282
+ * Bind the key, screening, integrity, freshness, and eviction logic to any
283
+ * {@link ColumnarBatchCacheStorage}.
284
+ *
285
+ * The returned handle never throws into a data path: a rejected backend call, a
286
+ * refused value, or a corrupt record settles as a miss or a refusal and reports
287
+ * a {@link ColumnarBatchCacheDiagnosticV1}, so a caller falls back to fetching
288
+ * rather than failing.
289
+ */
290
+ export declare function createColumnarBatchCache(storage: ColumnarBatchCacheStorage, options?: ColumnarBatchCacheOptions): ColumnarBatchCacheHandle;
291
+ /**
292
+ * In-process storage with the persistent backend's exact semantics: atomic
293
+ * write-plus-eviction, caller-owned reads, and no aliasing of a caller's bytes.
294
+ */
295
+ export declare function createMemoryColumnarBatchCacheStorage(): ColumnarBatchCacheStorage;
296
+ /** Shape gate for anything a backend hands back as a record. */
297
+ export declare function isCacheRecord(value: unknown): value is ColumnarBatchCacheRecordV1;
298
+ //# sourceMappingURL=batch-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-cache.d.ts","sourceRoot":"","sources":["../../../src/columnar/batch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAaH,OAAO,KAAK,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEtG,OAAO,EAAE,KAAK,iBAAiB,EAAuD,MAAM,gBAAgB,CAAC;AAC7G,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAuB,MAAM,YAAY,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,iCAAiC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