@voltro/kv 0.86.0 → 0.87.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 (54) hide show
  1. package/CHANGELOG.md +5321 -0
  2. package/README.md +110 -0
  3. package/THIRD-PARTY-NOTICES.md +864 -1
  4. package/dist/analytics.d.ts +337 -0
  5. package/dist/analytics.js +16 -0
  6. package/dist/cacheAtomicProtocol.js +247 -0
  7. package/dist/cacheAtomicScript.js +309 -0
  8. package/dist/cacheAtomicState.js +141 -0
  9. package/dist/connection.d.ts +990 -9
  10. package/dist/connection.js +330 -50
  11. package/dist/connectionAnalyticsConfig.js +153 -0
  12. package/dist/connectionConfigProvider.js +111 -0
  13. package/dist/connectionDefinitions.js +285 -0
  14. package/dist/connectionMemory.js +207 -0
  15. package/dist/connectionMetrics.js +79 -0
  16. package/dist/connectionNamespace.js +19 -0
  17. package/dist/connectionNats.js +148 -0
  18. package/dist/connectionNatsConfig.js +87 -0
  19. package/dist/connectionNatsSubjects.js +16 -0
  20. package/dist/connectionOwner.js +44 -0
  21. package/dist/connectionPool.js +738 -0
  22. package/dist/connectionPrefix.js +37 -0
  23. package/dist/connectionScripts.js +4 -0
  24. package/dist/connectionSqlConfig.js +119 -0
  25. package/dist/connectionStorageConfig.js +190 -0
  26. package/dist/connectionStorageFacade.js +78 -0
  27. package/dist/connectionSubscriber.js +130 -0
  28. package/dist/errors.js +5 -1
  29. package/dist/hot-contract.d.ts +297 -0
  30. package/dist/hot-contract.js +18 -0
  31. package/dist/hot-testing.d.ts +229 -0
  32. package/dist/hot-testing.js +1 -0
  33. package/dist/hot.d.ts +936 -0
  34. package/dist/hot.js +7 -0
  35. package/dist/hotMemory.js +46 -0
  36. package/dist/hotOperations.js +223 -0
  37. package/dist/hotRateLimit.js +103 -0
  38. package/dist/hotReadAvailability.js +19 -0
  39. package/dist/hotRedis.js +139 -0
  40. package/dist/hotRedisScript.js +4 -0
  41. package/dist/hotRouting.js +78 -0
  42. package/dist/hotState.js +182 -0
  43. package/dist/hotStoreConformance.js +367 -0
  44. package/dist/index.d.ts +113 -9
  45. package/dist/nativeRedisReads.js +78 -0
  46. package/dist/nativeRedisTopology.js +221 -0
  47. package/dist/redisDiagnostics.js +27 -0
  48. package/dist/redisReadPolicy.js +39 -0
  49. package/dist/sql.d.ts +77 -0
  50. package/dist/sql.js +0 -0
  51. package/dist/storage.d.ts +166 -0
  52. package/dist/storage.js +48 -0
  53. package/dist/storageAddress.js +20 -0
  54. package/package.json +43 -3
package/README.md CHANGED
@@ -24,3 +24,113 @@ deliberately short so there is nothing here to drift out of date.
24
24
 
25
25
  Proprietary. © 2026 Voltro UG. Your use is governed by the
26
26
  [Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
27
+ ## Native Redis topologies
28
+
29
+ RESP connection URLs distinguish standalone Redis, Cluster seeds and Sentinel
30
+ master groups. Secure schemes retain certificate verification; Sentinel can use
31
+ separate control credentials. Default and batch reads stay on primaries, scans visit
32
+ discovered primaries and cross-slot deletion has no cross-key atomicity promise.
33
+ Scheme names are case insensitive. Static, environment and tenant-resolved
34
+ credentials share metadata admission before transport acquisition.
35
+ Nonzero standalone/Sentinel databases require confirmed SELECT on every socket;
36
+ failed selection closes the transport instead of allowing database-zero commands.
37
+ Owned Pub/Sub sockets report gaps and acknowledge restored subscriptions before
38
+ reconnection. See [connections](https://docs.voltro.dev/docs/caching/connections)
39
+ for URL admission, migration, ownership and explicit eventual reads. Individual
40
+ HotStore reads may request `consistency: 'eventual'`; the connection selects
41
+ `readFrom: 'primary' | 'replica' | 'nearest'` through an owned read-only
42
+ port. Native/HTTP Lua uses EVAL_RO. `nearest` probes fresh roundtrip times.
43
+ Readers share tenant prefixes, rotation, leases and shutdown with the primary.
44
+ A lost mutation response is an unknown outcome and never authorizes replay.
45
+
46
+ ## Named Analytics
47
+
48
+ Declare analytical destinations under `connections.analytics` and select the
49
+ app-wide sink with `analytics: { connection: 'analytics:warehouse' }`. The
50
+ app owns the pool; handlers and plugins borrow it. Install the selected
51
+ provider package in the app. DuckDB does not require an application SQL store.
52
+
53
+ ```ts
54
+ import { env } from '@voltro/kv/connection'
55
+
56
+ export default {
57
+ name: 'analyticsApp',
58
+ type: 'api',
59
+ store: 'memory',
60
+ connections: {
61
+ analytics: {
62
+ warehouse: { provider: 'duckdb', path: env('DUCKDB_PATH') },
63
+ },
64
+ defaults: { analytics: 'warehouse' },
65
+ },
66
+ analytics: { connection: 'analytics:warehouse' },
67
+ }
68
+ ```
69
+
70
+ Declarations use `provider: 'duckdb' | 'clickhouse' | 'tinybird' | 'posthog'`.
71
+ Endpoints and credentials use `env()`; DuckDB paths may use strings or `env()`.
72
+ Operator overrides use `CONNECTIONS_ANALYTICS_<NAME>_<FIELD>`, including
73
+ `URL`, `USERNAME`, `PASSWORD`, `PATH`, `TOKEN`, `API_URL`, `API_KEY` and `HOST`.
74
+ The provider, identifiers, mirror tables and batching policy remain declared.
75
+ Production network destinations require HTTPS. Missing credentials refuse boot.
76
+
77
+ DuckDB and ClickHouse initialize their event schema before the read-only
78
+ readiness query; Tinybird checks the configured aggregate pipe without emitting
79
+ an event. PostHog acquisition currently refuses: its capture-key read-only probe
80
+ is unfinished. It is not a silent noop or an event-writing health check.
81
+
82
+ `dynamicAnalytics(resolve, { ttlMs })` declares a tenant-owned destination.
83
+ Borrow it with `registry.analytics('analytics:tenant', { tenantId })`; declaration
84
+ validation and inventory do not invoke the resolver. App-wide Analytics selection
85
+ requires a static declaration. A tenant-scoped destination must be borrowed in
86
+ its tenant context. The registry owns TTL/LRU bounds and disposal.
87
+
88
+ Borrowed sinks follow `registry.reload` and the app owner's SIGHUP handling.
89
+ Replacement readiness, provider, capabilities and mirror schema are checked
90
+ before switching; failure retains the old generation. Accepted calls retain
91
+ their generation until completion. Sink disposal never closes another consumer's
92
+ shared pool. Closing the app owner refuses new operations and awaits cleanup.
93
+
94
+ Connection inventory, the shared Connections panel and `voltro doctor
95
+ --connections` include Analytics references without paths, endpoints,
96
+ credentials or tenant IDs. Doctor probes initialize the provider schema before
97
+ measuring a read-only query; they do not prove event delivery or capacity.
98
+ Dynamic operator probes require an explicit tenant context.
99
+
100
+ Tests can inject an `AnalyticsConnectionConnector` into the registry or pass
101
+ `connectAnalytics` in `withConnections` options. The connector returns a sink,
102
+ read-only probe and owned close Effect. Tests must still supply valid declarations.
103
+ The browser-safe port and errors are exported from `@voltro/kv/analytics`; the
104
+ runtime re-exports the same contract without a second error implementation.
105
+
106
+ ## Unavailable read policy
107
+
108
+ Plugin connection roles declare `onUnavailable: 'degrade' | 'fail'`; omitted
109
+ policy means `fail`. The app passes each admitted role policy into plugin
110
+ lifecycle and store-binding contexts and shows it in connection inventory.
111
+ `readHotStoreWithFallback` from `@voltro/kv/hot/contract` exposes only HotStore
112
+ read methods. Under `degrade`, a typed unavailable read selects the caller's
113
+ explicit fallback once. SQL remains the durable source; the helper does not
114
+ write, rebuild or retry. Other failures and interruption remain failures.
115
+ Never invoke it from a Room tick.
116
+
117
+ ## Conditional lease ownership
118
+
119
+ `HotStore.compareDelete` and `compareExpire` atomically compare a `setNx` lease
120
+ value before removal or TTL renewal. Missing, expired and mismatched values
121
+ return false without changing a successor. Other structures fail with wrongType.
122
+ Use a fresh server-owned value per acquisition, outside ticks. Temporary leases
123
+ do not replace durable SQL revision/epoch fencing. Replacement ports must implement
124
+ both operations and their atomic batch variants; migration
125
+ `0.87.0/67_hot-store-conditional-leases` reports the contract. See the bilingual
126
+ [HotStore guide](https://docs.voltro.dev/docs/caching/hot-store).
127
+
128
+ ## Native command timeouts
129
+
130
+ RESP declarations, resolved dynamic configuration and direct `connect` accept
131
+ `connectTimeoutMs` and `commandTimeoutMs`. Values are integer milliseconds from
132
+ 1 through 2147483647; HTTP/memory refuse them. Native primary, reader and
133
+ subscriber construction shares these settings. A timed-out write remains an
134
+ unknown outcome, not cancelled or safe to replay. Existing ownership and
135
+ no-resend behavior remain authoritative. These are per-transport limits, not
136
+ an aggregate business-operation deadline. See the bilingual connections guide.