@voltro/runtime 0.86.0 → 0.88.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 (184) hide show
  1. package/CHANGELOG.md +5484 -0
  2. package/README.md +43 -0
  3. package/THIRD-PARTY-NOTICES.md +1511 -276
  4. package/dist/aggregate.js +1 -2
  5. package/dist/aggregateExtrema.js +1 -2
  6. package/dist/aggregateIvm.js +1 -2
  7. package/dist/analyticsMirror.js +1 -2
  8. package/dist/analyticsSink.js +9 -16
  9. package/dist/apiKeyUsage.js +1 -2
  10. package/dist/apiKeys.js +83 -80
  11. package/dist/apiKeysWiring.js +1 -2
  12. package/dist/apiRoleBucketSampler.js +63 -0
  13. package/dist/apiRoleWorkloadHistory.js +55 -0
  14. package/dist/apiRoleWorkloadMetrics.js +77 -0
  15. package/dist/apiRoleWorkloadStorage.js +94 -0
  16. package/dist/approvalBuiltins.js +1 -2
  17. package/dist/approvals.js +68 -76
  18. package/dist/authMiddlewareLayer.js +8 -8
  19. package/dist/bindEvent.js +49 -30
  20. package/dist/boot-refusal.d.ts +10 -0
  21. package/dist/{bootRefusal.js → boot-refusal.js} +1 -2
  22. package/dist/bootListener.js +203 -47
  23. package/dist/bootStoreCodec.js +39 -39
  24. package/dist/businessRules.js +1 -2
  25. package/dist/changeClaimsTable.js +1 -2
  26. package/dist/circuitBreaker.js +1 -72
  27. package/dist/columnOnUpdate.js +1 -2
  28. package/dist/composeAnalytics.js +32 -12
  29. package/dist/computedQuery.js +1 -2
  30. package/dist/computedQueryCache.js +289 -0
  31. package/dist/connectionBuiltins.js +1 -2
  32. package/dist/connectionCredentials.js +1 -2
  33. package/dist/connectionState.js +1 -2
  34. package/dist/connectionVault.js +1 -2
  35. package/dist/connectionsFacade.js +33 -32
  36. package/dist/coordinatedSchedule.js +85 -80
  37. package/dist/crdtHistory.js +1 -2
  38. package/dist/crdtMerge.js +1 -2
  39. package/dist/crdtVersionsTable.js +1 -2
  40. package/dist/credentialBound.js +1 -2
  41. package/dist/crud.js +1 -2
  42. package/dist/dataStore.js +155 -123
  43. package/dist/dataloader.js +1 -2
  44. package/dist/declaredTablesGuard.js +3 -3
  45. package/dist/defineExecutor.js +1 -2
  46. package/dist/dependencyGraph.js +1 -2
  47. package/dist/devices.js +1 -2
  48. package/dist/devicesWiring.js +1 -2
  49. package/dist/dialectReplicationAdapter.js +1 -2
  50. package/dist/dispatcher.js +404 -330
  51. package/dist/effectStore.js +3 -4
  52. package/dist/engineClients.js +23 -0
  53. package/dist/eventBus.js +1 -2
  54. package/dist/eventPublish.js +1 -2
  55. package/dist/events.js +1 -2
  56. package/dist/expectation.js +1 -2
  57. package/dist/expectationEvaluator.js +2 -3
  58. package/dist/experiment.js +1 -2
  59. package/dist/experimentEvaluator.js +1 -2
  60. package/dist/externalizedTasks.js +20 -8
  61. package/dist/fieldCipher.js +110 -42
  62. package/dist/fieldKeyRegistry.js +294 -0
  63. package/dist/fieldKeyRekey.js +285 -0
  64. package/dist/fieldKeyScan.js +135 -0
  65. package/dist/fieldKeyring.js +76 -0
  66. package/dist/fingerprint.js +1 -2
  67. package/dist/finops.js +1 -2
  68. package/dist/finopsAccountant.js +1 -2
  69. package/dist/handlerBody.js +1 -2
  70. package/dist/healthProbes.js +1 -2
  71. package/dist/hot.d.ts +56 -0
  72. package/dist/hot.js +3 -0
  73. package/dist/hotDataStore.js +147 -0
  74. package/dist/hotDataStoreSnapshot.js +97 -0
  75. package/dist/hotDataStoreTables.js +17 -0
  76. package/dist/http-range.d.ts +53 -0
  77. package/dist/http-range.js +51 -0
  78. package/dist/httpClientSsrf.js +13 -39
  79. package/dist/httpClientTracing.js +13 -11
  80. package/dist/httpCompression.js +18 -19
  81. package/dist/httpInputStream.js +81 -0
  82. package/dist/httpKeepAlive.js +1 -2
  83. package/dist/httpRouteMounts.js +2 -2
  84. package/dist/idempotencyStore.js +93 -54
  85. package/dist/idleDetector.js +1 -2
  86. package/dist/index.d.ts +1185 -452
  87. package/dist/index.js +144 -134
  88. package/dist/insertRequiredColumns.js +1 -2
  89. package/dist/instanceMembership.js +1 -2
  90. package/dist/ivm.js +1 -2
  91. package/dist/kvDataStore.js +1 -2
  92. package/dist/kvFacade.js +24 -19
  93. package/dist/matcher.js +1 -2
  94. package/dist/memoryColumnDefaults.js +1 -2
  95. package/dist/memoryQueryJoins.js +17 -18
  96. package/dist/memorySetOperations.js +42 -0
  97. package/dist/metrics.js +39 -26
  98. package/dist/observability.js +2 -3
  99. package/dist/observedGraph.js +1 -2
  100. package/dist/originGuard.js +1 -2
  101. package/dist/outbox.js +2 -3
  102. package/dist/pluginRefRules.js +1 -2
  103. package/dist/policyGuardResolver.js +1 -2
  104. package/dist/preview.js +1 -2
  105. package/dist/projectedRows.js +1 -2
  106. package/dist/provenance.js +1 -2
  107. package/dist/rangeIndex.js +1 -2
  108. package/dist/rawReadScope.js +2 -3
  109. package/dist/reaction.js +1 -2
  110. package/dist/reactiveConfig.js +1 -2
  111. package/dist/readClassification.js +1 -2
  112. package/dist/readRecorder.js +36 -36
  113. package/dist/readScopePredicate.js +11 -0
  114. package/dist/rebac.js +1 -2
  115. package/dist/rebacInterceptor.js +1 -2
  116. package/dist/registry.js +1 -2
  117. package/dist/relevantFields.js +1 -2
  118. package/dist/replicaHealth.js +1 -2
  119. package/dist/replicaLocality.js +1 -2
  120. package/dist/replicaObservations.js +1 -2
  121. package/dist/replicaSelection.js +1 -2
  122. package/dist/replicatedDataStore.js +23 -6
  123. package/dist/requestLoader.js +1 -2
  124. package/dist/resumeCensus.js +1 -2
  125. package/dist/revalidation.js +1 -2
  126. package/dist/rowFilter.js +57 -41
  127. package/dist/rowStateBytes.js +1 -2
  128. package/dist/rpcBodyCap.js +1 -2
  129. package/dist/rpcConnections.js +9 -10
  130. package/dist/rpcDefectDiagnostics.js +1 -2
  131. package/dist/rpcServer.js +523 -451
  132. package/dist/rpcWorkloadAdmission.js +49 -0
  133. package/dist/runAsSystem.js +1 -2
  134. package/dist/rywPositionStore.js +83 -49
  135. package/dist/schedule.js +1 -2
  136. package/dist/scheduleBackfillRequests.js +1 -2
  137. package/dist/scheduleClaimsTable.js +1 -2
  138. package/dist/scheduleRunsTable.js +1 -2
  139. package/dist/scheduler.js +7 -3
  140. package/dist/schemaRegistry.js +1 -2
  141. package/dist/secretsResolver.js +1 -2
  142. package/dist/securityHeaders.js +1 -2
  143. package/dist/servePipeline.js +238 -154
  144. package/dist/serverOnlyAudit.js +1 -2
  145. package/dist/serverTracer.js +1 -2
  146. package/dist/serviceCredentials.js +1 -2
  147. package/dist/setReadScopes.js +27 -0
  148. package/dist/singleNodeOrchestrator.js +1 -2
  149. package/dist/snapshotValueCodec.js +45 -0
  150. package/dist/sourceResolution.js +35 -26
  151. package/dist/storeMiddleware.js +213 -212
  152. package/dist/storeQuery.js +1 -2
  153. package/dist/storeRead.js +1 -2
  154. package/dist/subscriber.js +2 -2
  155. package/dist/subscriptionOutbox.js +1 -2
  156. package/dist/subscriptionRegistry.js +1 -2
  157. package/dist/subscriptionResume.js +1 -2
  158. package/dist/subscriptionSocketMetrics.js +1 -2
  159. package/dist/systemSubject.js +1 -2
  160. package/dist/tenantScope.js +9 -22
  161. package/dist/tenantSelection.js +1 -2
  162. package/dist/timeline.js +1 -2
  163. package/dist/traceContext.js +1 -2
  164. package/dist/traceSink.js +1 -2
  165. package/dist/traceSpansTable.js +1 -2
  166. package/dist/traceparent.js +9 -21
  167. package/dist/transactionSubject.js +1 -2
  168. package/dist/trustedProxy.js +2 -3
  169. package/dist/undo.js +1 -2
  170. package/dist/undoBuiltins.js +1 -2
  171. package/dist/undoCapture.js +1 -2
  172. package/dist/undoLogTable.js +1 -2
  173. package/dist/upsertBinding.js +1 -2
  174. package/dist/wakeOrchestrator.js +1 -2
  175. package/dist/wakeRegistry.js +1 -2
  176. package/dist/wakeRouter.js +1 -2
  177. package/dist/wakeSupervisor.js +1 -2
  178. package/dist/wakeupsTable.js +1 -2
  179. package/dist/webSocketGatewayRuntime.js +112 -73
  180. package/dist/webhookVerification.js +1 -2
  181. package/dist/wireColumnStrip.js +1 -2
  182. package/dist/workflowReadBuiltins.js +1 -2
  183. package/dist/workflowRuntime.js +10 -11
  184. package/package.json +36 -17
@@ -1,5 +1,5 @@
1
1
  import { getTable as e } from "@voltro/database";
2
- //#region src/memoryColumnDefaults.ts
2
+ // src/memoryColumnDefaults.ts
3
3
  var t = (t, n) => {
4
4
  let r = e(t);
5
5
  if (r === void 0) return n;
@@ -7,5 +7,4 @@ var t = (t, n) => {
7
7
  for (let [e, t] of Object.entries(r.fields)) i[e] === void 0 && t.generatedAs === void 0 && t.computed === void 0 && (t.hasDefault && t.defaultFactory === void 0 && t.defaultValue !== void 0 ? i[e] = t.defaultValue === "now" ? /* @__PURE__ */ new Date() : structuredClone(t.defaultValue) : t.nullable && t.defaultFactory === void 0 && (i[e] = null));
8
8
  return i;
9
9
  };
10
- //#endregion
11
10
  export { t as applyMemoryColumnDefaults };
@@ -1,5 +1,5 @@
1
1
  import { evaluatePredicate as e, getTable as t, isColumnReference as n, preparePredicate as r } from "@voltro/database";
2
- //#region src/memoryQueryJoins.ts
2
+ // src/memoryQueryJoins.ts
3
3
  var i = (e) => e == null || typeof e == "string" || typeof e == "boolean" || typeof e == "bigint" || typeof e == "number" && !Number.isNaN(e), a = (e, t = /* @__PURE__ */ new WeakSet()) => {
4
4
  if (typeof e != "object" || !e || Object.getPrototypeOf(e) !== Object.prototype || t.has(e)) return !1;
5
5
  t.add(e);
@@ -18,15 +18,13 @@ var i = (e) => e == null || typeof e == "string" || typeof e == "boolean" || typ
18
18
  return !0;
19
19
  }, o = (e, t) => {
20
20
  if ("and" in e) {
21
- for (let n of e.and) {
22
- let e = o(n, t);
23
- if (e) return e;
24
- }
25
- return;
21
+ let n = [];
22
+ for (let r = 0; r < e.and.length; r += 1) n.push(...o(e.and[r], t));
23
+ return n;
26
24
  }
27
- if (!("op" in e) || e.op !== "eq" || e.path !== void 0 || !n(e.value)) return;
25
+ if (!("op" in e) || e.op !== "eq" || e.path !== void 0 || !n(e.value)) return [];
28
26
  let r = e.column, i = e.value.column, a = `${t}.`;
29
- if (r.startsWith(a) !== i.startsWith(a)) return r.startsWith(a) ? [i, r] : [r, i];
27
+ return r.startsWith(a) === i.startsWith(a) ? [] : [r.startsWith(a) ? [i, r] : [r, i]];
30
28
  }, s = (n, s, c, l) => {
31
29
  let u = n.alias ?? n.table, d = (n.sourceTable?.tableName === n.table ? n.sourceTable : t(n.table))?.fields ?? {}, f = new Set(Object.keys(d));
32
30
  for (let e of s) for (let t of Object.keys(e)) f.add(t);
@@ -71,18 +69,20 @@ var i = (e) => e == null || typeof e == "string" || typeof e == "boolean" || typ
71
69
  }) : t[r] = i;
72
70
  }
73
71
  return t;
74
- }, _ = u.map(m), y = l(s.on), b, x = _.length * v.length < 16, S = !1, C, w = o(s.on, s.alias), T;
75
- if (w && h[w[0]]?.type !== "decimal" && h[w[1]]?.type !== "decimal" && _.every((e) => i(e[w[1]]))) {
76
- T = /* @__PURE__ */ new Map();
77
- for (let e of _) {
78
- let t = e[w[1]];
79
- if (t == null) continue;
80
- let n = T.get(t);
81
- n ? n.push(e) : T.set(t, [e]);
72
+ }, _ = u.map(m), y = l(s.on), b, x = _.length * v.length < 16, S = !1, C, w = o(s.on, s.alias), T, E;
73
+ for (let e of w) {
74
+ if (h[e[0]]?.type === "decimal" || h[e[1]]?.type === "decimal" || !_.every((t) => i(t[e[1]]))) continue;
75
+ let t = /* @__PURE__ */ new Map();
76
+ for (let n of _) {
77
+ let r = n[e[1]];
78
+ if (r == null) continue;
79
+ let i = t.get(r);
80
+ i ? i.push(n) : t.set(r, [n]);
82
81
  }
82
+ (E === void 0 || t.size > E.size) && (T = e, E = t);
83
83
  }
84
84
  v = v.flatMap((t) => {
85
- let n = w === void 0 ? void 0 : t[w[0]], o = T && i(n) ? n == null ? [] : T.get(n) ?? [] : _, c = x ? o.map((e) => ({
85
+ let n = T === void 0 ? void 0 : t[T[0]], o = E && i(n) ? n == null ? [] : E.get(n) ?? [] : _, c = x ? o.map((e) => ({
86
86
  ...t,
87
87
  ...e
88
88
  })).filter((t) => e(s.on, t, y, h)) : [];
@@ -110,5 +110,4 @@ var i = (e) => e == null || typeof e == "string" || typeof e == "boolean" || typ
110
110
  project: (e) => n.joinedProjection?.length ? Object.fromEntries(n.joinedProjection.map((t) => [t.outputKey, e[t.source]])) : Object.fromEntries((n.projection ?? p).map((t) => [t, e[t]]))
111
111
  };
112
112
  };
113
- //#endregion
114
113
  export { s as memoryQueryJoins };
@@ -0,0 +1,42 @@
1
+ import { decimalEqualityKey as e, getTable as t } from "@voltro/database";
2
+ // src/memorySetOperations.ts
3
+ var n = (e, t = !1) => e == null ? ["null"] : e instanceof Date ? t ? ["string", e.toISOString()] : ["date", e.getTime()] : typeof e == "bigint" ? ["bigint", e.toString()] : typeof e == "number" ? t && !Number.isFinite(e) ? ["null"] : ["number", Number.isFinite(e) ? e : String(e)] : typeof e == "object" ? e instanceof ArrayBuffer ? ["bytes", [...new Uint8Array(e)]] : ArrayBuffer.isView(e) ? ["bytes", [...new Uint8Array(e.buffer, e.byteOffset, e.byteLength)]] : Array.isArray(e) ? ["array", e.map((e) => n(e, t))] : ["object", Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, r]) => [e, n(r, t)])] : [typeof e, e], r = (t, r, i) => JSON.stringify(r.map((r) => {
4
+ let a = t[r], o = a == null || i[r]?.type !== "decimal" ? null : e(a);
5
+ return o === null ? n(a, i[r]?.type === "json") : ["decimal", o];
6
+ })), i = (e, n) => {
7
+ if (e.setOp) return i(e.setOp.queries[0], n);
8
+ let r = (e.sourceTable ?? t(e.table))?.fields ?? {}, a = { ...r }, o = e.alias ?? e.table;
9
+ for (let [e, t] of Object.entries(r)) a[`${o}.${e}`] = t;
10
+ for (let n of e.joins ?? []) {
11
+ let e = (n.sourceTable ?? t(n.table))?.fields ?? {};
12
+ for (let [t, r] of Object.entries(e)) a[`${n.alias}.${t}`] = r;
13
+ }
14
+ if (e.aggregations?.length) return Object.fromEntries(e.aggregations.map((e) => {
15
+ let t = e.column === void 0 ? { type: "unknown" } : a[e.column] ?? { type: "unknown" }, n = e.op === "count" || e.op === "count-distinct" || e.op === "window-row-number" || e.op === "window-rank" || e.op === "window-dense-rank", r = e.op === "avg" || e.op === "window-avg-over";
16
+ return [e.alias, n ? { type: "integer" } : r && t.type !== "decimal" ? { type: "real" } : t];
17
+ }));
18
+ if (e.joinedProjection) return Object.fromEntries(e.joinedProjection.map((e) => [e.outputKey, a[e.source] ?? { type: "unknown" }]));
19
+ let s = e.projection ?? (Object.keys(r).length > 0 ? Object.keys(r) : [...new Set(n.flatMap((e) => Object.keys(e)))]);
20
+ return Object.fromEntries(s.map((e) => [e, a[e] ?? { type: "unknown" }]));
21
+ }, a = (e, t) => {
22
+ let n = e.setOp;
23
+ if (!n || n.queries.length < 2) throw Error("A set operation requires at least two inputs");
24
+ let a = n.queries.map((e) => ({
25
+ rows: t(e),
26
+ query: e
27
+ })), o = a.map((e) => i(e.query, e.rows)), s = o[0], c = Object.keys(s), l = a.map((e, t) => {
28
+ let n = Object.keys(o[t]);
29
+ if (n.length !== c.length) throw Error("Set operation inputs must have the same column count");
30
+ return e.rows.map((e) => Object.fromEntries(c.map((t, r) => [t, e[n[r]] ?? null])));
31
+ });
32
+ if (n.kind === "union-all") return l.flat();
33
+ let u = (e) => new Map(e.map((e) => [r(e, c, s), e]));
34
+ if (n.kind === "union") return [...u(l.flat()).values()];
35
+ let d = u(l[0]);
36
+ for (let e of l.slice(1)) {
37
+ let t = u(e);
38
+ for (let e of d.keys()) (n.kind === "intersect" ? !t.has(e) : t.has(e)) && d.delete(e);
39
+ }
40
+ return [...d.values()];
41
+ };
42
+ export { i as memoryOutputColumns, r as memoryRowKey, a as memorySetRows };
package/dist/metrics.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { subscriptionSocketMetricSamples as e } from "./subscriptionSocketMetrics.js";
2
2
  import { Effect as t, Metric as n } from "effect";
3
- //#region src/metrics.ts
3
+ // src/metrics.ts
4
4
  var r = n.exponentialBoundaries({
5
5
  start: .001,
6
6
  factor: 2,
@@ -17,7 +17,7 @@ var r = n.exponentialBoundaries({
17
17
  }), u = n.counter("voltro_plugin_hook_errors_total", { description: "Plugin interceptor invocations that errored." }), d = n.counter("voltro_subscription_deliveries_total", { description: "Total subscription deliveries (snapshot + delta)." }), f = n.histogram("voltro_subscription_delivery_seconds", {
18
18
  boundaries: r,
19
19
  description: "Subscription delivery produce→push latency in seconds."
20
- }), ee = n.gauge("voltro_subscriptions_active", { description: "Currently-open subscriptions." }), p = n.counter("voltro_schedule_runs_total", { description: "Schedule firings by name + outcome." }), m = n.histogram("voltro_schedule_duration_seconds", {
20
+ }), p = n.gauge("voltro_subscriptions_active", { description: "Currently-open subscriptions." }), m = n.counter("voltro_schedule_runs_total", { description: "Schedule firings by name + outcome." }), ee = n.histogram("voltro_schedule_duration_seconds", {
21
21
  boundaries: r,
22
22
  description: "Schedule handler duration in seconds."
23
23
  }), h = n.gauge("voltro_schedule_last_success_timestamp_seconds", { description: "UNIX time of the last successful firing, per schedule." }), g = n.gauge("voltro_schedule_queued", { description: "Firings waiting for their turn under onOverlap: 'queue', per schedule, on THIS replica." }), _ = n.histogram("voltro_schedule_queue_wait_seconds", {
@@ -36,11 +36,11 @@ var r = n.exponentialBoundaries({
36
36
  O.clear();
37
37
  }, j = () => O.size, M = (e) => {
38
38
  t.runSync(n.update(k(w, `p:${e}`, [["event", e]]), 1));
39
- }, te = (e, r = 1) => {
39
+ }, N = (e, r = 1) => {
40
40
  r <= 0 || t.runSync(n.update(k(T, `d:${e}`, [["event", e]]), r));
41
- }, N = (e, r, i = 1) => {
41
+ }, P = (e, r, i = 1) => {
42
42
  i <= 0 || t.runSync(n.update(k(E, `x:${r}:${e}`, [["event", e], ["reason", r]]), i));
43
- }, P = (e, r) => {
43
+ }, te = (e, r) => {
44
44
  r !== 0 && t.runSync(n.update(k(D, `s:${e}`, [["event", e]]), r));
45
45
  }, F = (e) => {
46
46
  let r = e.durationMs / 1e3, d = e.kind === "rpc" ? t.andThen(n.update(i, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
@@ -51,8 +51,22 @@ var r = n.exponentialBoundaries({
51
51
  status: e.status
52
52
  })), n.update(c, r).pipe(t.provideService(n.CurrentMetricAttributes, { route: e.tag }))) : t.andThen(n.update(l, r).pipe(t.provideService(n.CurrentMetricAttributes, { hook: e.tag })), e.status === "error" ? n.update(u, 1).pipe(t.provideService(n.CurrentMetricAttributes, { hook: e.tag })) : t.void);
53
53
  t.runSync(d);
54
- }, I = (e) => e.startsWith("subscription.") ? e.slice(13) : e, L = (e) => {
55
- let r = I(e.label);
54
+ }, I = n.counter("voltro_field_decrypts_total", { description: "Opens of sealed field values, by key id, location (table:column) and outcome." }), L = /* @__PURE__ */ new Map(), R = (e, r, i) => {
55
+ let a = `${e}|${r}`, o = L.get(a) ?? L.set(a, {
56
+ key: e,
57
+ location: r,
58
+ ok: 0,
59
+ failed: 0
60
+ }).get(a);
61
+ o[i] += 1, t.runSync(n.update(k(I, `field|${a}|${i}`, [
62
+ ["key", e],
63
+ ["location", r],
64
+ ["outcome", i]
65
+ ]), 1));
66
+ }, z = () => [...L.values()].map((e) => ({ ...e })).sort((e, t) => e.location.localeCompare(t.location) || e.key.localeCompare(t.key)), B = () => {
67
+ L.clear();
68
+ }, V = (e) => e.startsWith("subscription.") ? e.slice(13) : e, H = (e) => {
69
+ let r = V(e.label);
56
70
  t.runSync(t.andThen(n.update(d, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
57
71
  tag: r,
58
72
  kind: e.kind
@@ -60,42 +74,42 @@ var r = n.exponentialBoundaries({
60
74
  tag: r,
61
75
  kind: e.kind
62
76
  }))));
63
- }, R = /* @__PURE__ */ new Map(), z = (e, r) => {
64
- let i = I(e), a = Math.max(0, (R.get(i) ?? 0) + r);
65
- a === 0 ? R.delete(i) : R.set(i, a), t.runSync(n.update(ee, a).pipe(t.provideService(n.CurrentMetricAttributes, { tag: i })));
66
- }, B = (e) => {
67
- let r = n.update(p, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
77
+ }, U = /* @__PURE__ */ new Map(), W = (e, r) => {
78
+ let i = V(e), a = Math.max(0, (U.get(i) ?? 0) + r);
79
+ a === 0 ? U.delete(i) : U.set(i, a), t.runSync(n.update(p, a).pipe(t.provideService(n.CurrentMetricAttributes, { tag: i })));
80
+ }, G = (e) => {
81
+ let r = n.update(m, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
68
82
  schedule: e.name,
69
83
  status: e.status
70
- })), i = n.update(m, e.durationMs / 1e3).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e.name })), a = e.status === "succeeded" && e.completedAtSec !== void 0 ? n.update(h, e.completedAtSec).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e.name })) : t.void;
84
+ })), i = n.update(ee, e.durationMs / 1e3).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e.name })), a = e.status === "succeeded" && e.completedAtSec !== void 0 ? n.update(h, e.completedAtSec).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e.name })) : t.void;
71
85
  t.runSync(t.andThen(r, t.andThen(i, a)));
72
- }, V = /* @__PURE__ */ new Map(), H = (e, r) => {
73
- let i = Math.max(0, (V.get(e) ?? 0) + r);
74
- i === 0 ? V.delete(e) : V.set(e, i), t.runSync(n.update(g, i).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e })));
75
- }, U = (e, r) => {
86
+ }, K = /* @__PURE__ */ new Map(), q = (e, r) => {
87
+ let i = Math.max(0, (K.get(e) ?? 0) + r);
88
+ i === 0 ? K.delete(e) : K.set(e, i), t.runSync(n.update(g, i).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e })));
89
+ }, J = (e, r) => {
76
90
  t.runSync(n.update(_, r / 1e3).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e })));
77
- }, W = (e, r) => {
91
+ }, Y = (e, r) => {
78
92
  t.runSync(n.update(v, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
79
93
  schedule: e,
80
94
  outcome: r
81
95
  })));
82
- }, G = (e, r) => {
96
+ }, X = (e, r) => {
83
97
  t.runSync(n.update(y, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
84
98
  schedule: e,
85
99
  outcome: r
86
100
  })));
87
- }, K = (e, r = 1) => {
101
+ }, Z = (e, r = 1) => {
88
102
  r <= 0 || t.runSync(n.update(b, r).pipe(t.provideService(n.CurrentMetricAttributes, { schedule: e })));
89
- }, q = (e) => {
103
+ }, Q = (e) => {
90
104
  let r = n.update(x, 1).pipe(t.provideService(n.CurrentMetricAttributes, {
91
105
  workflow: e.name,
92
106
  status: e.status
93
107
  })), i = n.update(S, e.durationMs / 1e3).pipe(t.provideService(n.CurrentMetricAttributes, { workflow: e.name })), a = e.status === "succeeded" && e.completedAtSec !== void 0 ? n.update(C, e.completedAtSec).pipe(t.provideService(n.CurrentMetricAttributes, { workflow: e.name })) : t.void;
94
108
  t.runSync(t.andThen(r, t.andThen(i, a)));
95
- }, J = (e, t) => n.counter(e, t === void 0 ? {} : { description: t }), Y = (e, t) => n.gauge(e, t === void 0 ? {} : { description: t }), X = (e, t = r, i) => n.histogram(e, {
109
+ }, ne = (e, t) => n.counter(e, t === void 0 ? {} : { description: t }), re = (e, t) => n.gauge(e, t === void 0 ? {} : { description: t }), ie = (e, t = r, i) => n.histogram(e, {
96
110
  boundaries: t,
97
111
  ...i === void 0 ? {} : { description: i }
98
- }), { exponentialBoundaries: Z, linearBoundaries: Q } = n, $ = n.snapshot.pipe(t.map((e) => e.map((e) => {
112
+ }), { exponentialBoundaries: ae, linearBoundaries: oe } = n, $ = n.snapshot.pipe(t.map((e) => e.map((e) => {
99
113
  let t = e.id, n = { ...e.attributes ?? {} }, r = e.description === void 0 ? {} : { description: e.description };
100
114
  switch (e.type) {
101
115
  case "Histogram": return {
@@ -156,6 +170,5 @@ var r = n.exponentialBoundaries({
156
170
  let n = e();
157
171
  for (let e of n) t.push(e);
158
172
  return t;
159
- })), ne = () => t.runSync($);
160
- //#endregion
161
- export { J as counter, j as eventMetricTagCacheSizeForTests, Z as exponentialBoundaries, Y as gauge, X as histogramMetric, Q as linearBoundaries, te as recordEventDelivered, N as recordEventDropped, M as recordEventPublished, P as recordEventSubscribers, K as recordExternalMissed, G as recordExternalTrigger, F as recordSample, W as recordScheduleQueueRecovery, U as recordScheduleQueueWait, H as recordScheduleQueued, B as recordScheduleRun, z as recordSubscriptionActive, L as recordSubscriptionDelivery, q as recordWorkflowRun, A as resetEventMetricTagCacheForTests, $ as snapshotMetrics, ne as snapshotMetricsSync };
173
+ })), se = () => t.runSync($);
174
+ export { ne as counter, j as eventMetricTagCacheSizeForTests, ae as exponentialBoundaries, z as fieldDecryptSnapshot, re as gauge, ie as histogramMetric, oe as linearBoundaries, N as recordEventDelivered, P as recordEventDropped, M as recordEventPublished, te as recordEventSubscribers, Z as recordExternalMissed, X as recordExternalTrigger, R as recordFieldDecrypt, F as recordSample, Y as recordScheduleQueueRecovery, J as recordScheduleQueueWait, q as recordScheduleQueued, G as recordScheduleRun, W as recordSubscriptionActive, H as recordSubscriptionDelivery, Q as recordWorkflowRun, A as resetEventMetricTagCacheForTests, B as resetFieldDecryptCountsForTests, $ as snapshotMetrics, se as snapshotMetricsSync };
@@ -1,7 +1,7 @@
1
- import { bootRefusal as e } from "./bootRefusal.js";
1
+ import { bootRefusal as e } from "./boot-refusal.js";
2
2
  import { Context as t, Effect as n, Layer as r, Option as i, Tracer as a } from "effect";
3
3
  import { AsyncLocalStorage as o } from "node:async_hooks";
4
- //#region src/observability.ts
4
+ // src/observability.ts
5
5
  var s = () => {
6
6
  let e = process.env.FRAMEWORK_TRACING?.toLowerCase();
7
7
  return e === "console" || e === "otlp" || e === "off" ? e : process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ? "otlp" : "off";
@@ -119,5 +119,4 @@ var s = () => {
119
119
  inMemoryMetricExporter: O
120
120
  };
121
121
  };
122
- //#endregion
123
122
  export { m as buildTracingLayer, l as describeOtelReasons, d as otelImportFailure };
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage as e } from "node:async_hooks";
2
- //#region src/observedGraph.ts
2
+ // src/observedGraph.ts
3
3
  var t = new e(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = "\0", a = process.env.VOLTRO_OBSERVE_GRAPH === "1", o = () => {
4
4
  a = !0;
5
5
  }, s = () => a, c = (e, n) => a ? (r.add(e.tag), t.run(e, n)) : n(), l = (e, r) => {
@@ -48,5 +48,4 @@ var t = new e(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i
48
48
  }
49
49
  return t;
50
50
  };
51
- //#endregion
52
51
  export { o as enableGraphObservation, s as isObservingGraph, f as observeStore, u as observedGraph, l as recordTableAccess, d as resetObservedGraph, c as runWithObservedProcedure };
@@ -1,4 +1,4 @@
1
- //#region src/originGuard.ts
1
+ // src/originGuard.ts
2
2
  var e = (e) => {
3
3
  let t = e.toUpperCase();
4
4
  return t !== "GET" && t !== "HEAD" && t !== "OPTIONS";
@@ -112,5 +112,4 @@ var e = (e) => {
112
112
  allowedOrigins: (i !== void 0 && i.length > 0 ? i : (t.VOLTRO_ALLOWED_ORIGINS ?? "").split(",").map((e) => e.trim()).filter((e) => e.length > 0)).map(a)
113
113
  };
114
114
  };
115
- //#endregion
116
115
  export { u as classifyRequestOrigin, e as isStateChangingMethod, r as makeOriginGuardExemption, a as normalizeOrigin, d as resolveOriginGuardConfig };
package/dist/outbox.js CHANGED
@@ -2,7 +2,7 @@ import { Effect as e } from "effect";
2
2
  import { and as t, eq as n, generateId as r, id as i, inSet as a, integer as o, json as s, lt as c, table as l, text as u, timestamp as d } from "@voltro/database";
3
3
  import { validateOutboxHandlerDefinition as f } from "@voltro/protocol";
4
4
  import { createLogger as p } from "@voltro/logger";
5
- //#region src/outbox.ts
5
+ // src/outbox.ts
6
6
  var m = p({ scope: "voltro:outbox" }), h = "_voltro_outbox", g = {
7
7
  kind: "typeid",
8
8
  prefix: "obx"
@@ -285,7 +285,7 @@ var m = p({ scope: "voltro:outbox" }), h = "_voltro_outbox", g = {
285
285
  subjectId: t.subjectId ?? null,
286
286
  tenantId: t.tenantId ?? null,
287
287
  traceId: t.traceId ?? null
288
- }, a = o.handler(i), c = e.isEffect(a) ? a : await a, d = e.isEffect(c) ? await (r.runEffect ? r.runEffect(c, i) : e.runPromise(c)) : c;
288
+ }, a = r.measureSync ? r.measureSync(() => o.handler(i)) : o.handler(i), c = e.isEffect(a) ? a : await a, d = e.isEffect(c) ? await (r.runEffect ? r.runEffect(c, i) : e.runPromise(c)) : c;
289
289
  await k(r.store, {
290
290
  outboxRow: t,
291
291
  attempt: s,
@@ -348,5 +348,4 @@ var m = p({ scope: "voltro:outbox" }), h = "_voltro_outbox", g = {
348
348
  ...p === void 0 ? {} : { nextAttemptAt: p }
349
349
  };
350
350
  };
351
- //#endregion
352
351
  export { T as DEFAULT_OUTBOX_CLAIM_LEASE_MS, v as OUTBOX_ATTEMPTS_TABLE, E as OUTBOX_ATTEMPT_LOG_CAP, h as OUTBOX_TABLE, w as backoffMs, x as defineOutboxHandler, M as drainOutbox, C as makeOutboxFacade, b as outboxAttemptsTable, _ as outboxTable };
@@ -1,5 +1,5 @@
1
1
  import { and as e, eq as t } from "@voltro/database";
2
- //#region src/pluginRefRules.ts
2
+ // src/pluginRefRules.ts
3
3
  var n = (e) => e.old ?? e.new ?? {}, r = (e) => String(n(e).id ?? ""), i = (e) => {
4
4
  let t = n(e).tenantId;
5
5
  return typeof t == "string" ? t : null;
@@ -61,5 +61,4 @@ var n = (e) => e.old ?? e.new ?? {}, r = (e) => String(n(e).id ?? ""), i = (e) =
61
61
  }
62
62
  return n.filter((e) => e.policy !== "keep");
63
63
  };
64
- //#endregion
65
64
  export { c as applyPluginRefRules, l as collectPluginRefRules, s as collectReferenceSoftDeleteRules, a as isSoftDelete, o as rulesFor };
@@ -3,7 +3,7 @@ import { currentRequestLoader as n } from "./requestLoader.js";
3
3
  import { Effect as r } from "effect";
4
4
  import { setPolicyGuardResolver as i } from "@voltro/protocol";
5
5
  import { createLogger as a } from "@voltro/logger";
6
- //#region src/policyGuardResolver.ts
6
+ // src/policyGuardResolver.ts
7
7
  var o = a({ scope: "voltro:policy" }), s, c = (e) => {
8
8
  s = e;
9
9
  }, l = () => s, u = (e) => s === void 0 && (s = e, !0), d = () => {
@@ -51,5 +51,4 @@ var o = a({ scope: "voltro:policy" }), s, c = (e) => {
51
51
  });
52
52
  }));
53
53
  };
54
- //#endregion
55
54
  export { l as getTupleSource, d as installPolicyGuardResolver, u as registerDefaultTupleSource, c as setTupleSource };
package/dist/preview.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/preview.ts
1
+ // src/preview.ts
2
2
  var e = (e) => {
3
3
  let t = e.new?.id;
4
4
  if (typeof t == "string") return t;
@@ -58,5 +58,4 @@ var e = (e) => {
58
58
  if (!i) throw Error("preview: handler did not complete");
59
59
  return n;
60
60
  };
61
- //#endregion
62
61
  export { n as buildPreview, t as diffChange, i as previewInRollback };
@@ -1,4 +1,4 @@
1
- //#region src/projectedRows.ts
1
+ // src/projectedRows.ts
2
2
  var e = (e, t) => {
3
3
  let n = [], r = e.length;
4
4
  for (let i = 0; i < r; i += 1) {
@@ -8,5 +8,4 @@ var e = (e, t) => {
8
8
  }
9
9
  return n;
10
10
  };
11
- //#endregion
12
11
  export { e as collectProjectedRows };
@@ -1,4 +1,4 @@
1
- //#region src/provenance.ts
1
+ // src/provenance.ts
2
2
  var e = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.length > 0 ? e : null, t = (e) => typeof e == "string" && e.length > 0 ? e : null, n = [
3
3
  "updatedAt",
4
4
  "createdAt",
@@ -59,5 +59,4 @@ var e = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" && e.l
59
59
  found: i.length > 0
60
60
  };
61
61
  };
62
- //#endregion
63
62
  export { a as historyProvenance, i as lastWriteProvenance };
@@ -1,4 +1,4 @@
1
- //#region src/rangeIndex.ts
1
+ // src/rangeIndex.ts
2
2
  var e = (e) => e?.height ?? 0, t = (t) => (t.height = 1 + Math.max(e(t.left), e(t.right)), t), n = (e) => {
3
3
  let n = e.left;
4
4
  return e.left = n.right, n.right = t(e), t(n);
@@ -85,5 +85,4 @@ var e = (e) => e?.height ?? 0, t = (t) => (t.height = 1 + Math.max(e(t.left), e(
85
85
  return r;
86
86
  }
87
87
  };
88
- //#endregion
89
88
  export { l as RangeIndex };
@@ -1,11 +1,11 @@
1
1
  import { resolveReactiveConfig as e } from "./reactiveConfig.js";
2
2
  import { AsyncLocalStorage as t } from "node:async_hooks";
3
- //#region src/rawReadScope.ts
3
+ // src/rawReadScope.ts
4
4
  var n = new t(), r = () => {
5
5
  n.getStore() !== void 0 && n.enterWith({ observations: [] });
6
6
  }, i = (t) => {
7
7
  let r = n.getStore();
8
- r === void 0 && (r = { observations: [] }, n.enterWith(r)), r.membership !== void 0 && !a(t) && (r.membership = void 0, r.exposed = !0), !r.exposed && r.membership === void 0 && r.observations.length >= 128 && a(t) && (r.observations.every(a) ? r.membership = new Set(r.observations.map((e) => e.sql)) : r.exposed = !0), !(r.membership?.has(t.sql) ?? r.observations.some((e) => e.sql === t.sql)) && (r.observations.length >= e().rawReadTrackingLimit || (r.observations.push(t), r.membership?.add(t.sql)));
8
+ r === void 0 && (r = { observations: [] }, n.enterWith(r)), r.membership !== void 0 && !a(t) && (r.membership = void 0, r.exposed = !0), !r.exposed && r.membership === void 0 && r.observations.length >= 128 && a(t) && (r.observations.every(a) ? r.membership = new Set(r.observations.map((e) => e.sql)) : r.exposed = !0), (r.membership?.has(t.sql) ?? r.observations.some((e) => e.sql === t.sql)) || r.observations.length >= e().rawReadTrackingLimit || (r.observations.push(t), r.membership?.add(t.sql));
9
9
  }, a = (e) => {
10
10
  let t = Object.getOwnPropertyDescriptor(e, "sql");
11
11
  return Object.isFrozen(e) && t !== void 0 && "value" in t && typeof t.value == "string";
@@ -13,5 +13,4 @@ var n = new t(), r = () => {
13
13
  let e = n.getStore();
14
14
  return e === void 0 ? [] : (e.exposed = !0, e.membership = void 0, e.observations);
15
15
  }, s = (e) => n.run({ observations: [] }, e), c = (e) => e.join("?").replace(/\s+/g, " ").trim();
16
- //#endregion
17
16
  export { o as currentRawReads, r as isolateRawReadScope, c as rawSqlPreview, i as recordRawRead, s as runWithRawReadScope };
package/dist/reaction.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/reaction.ts
1
+ // src/reaction.ts
2
2
  var e = (e) => typeof e.query == "string", t = (t) => e(t.watch), n = /^(\d+(?:\.\d+)?)\s*(ms|milliseconds?|s|seconds?|m|minutes?|h|hours?|d|days?)$/i, r = (e, t, r) => {
3
3
  if (typeof e == "number") {
4
4
  if (!Number.isFinite(e) || e <= 0) throw Error(`reaction '${r}': ${t} must be a positive duration`);
@@ -81,5 +81,4 @@ var c = (e) => {
81
81
  via: "agent"
82
82
  }), "acted");
83
83
  };
84
- //#endregion
85
84
  export { i as DEFAULT_LEVEL_RESYNC_MS, o as DEFAULT_LEVEL_STUCK_MS, a as MIN_LEVEL_RESYNC_MS, d as ReactionRateLimiter, s as defineReaction, t as isLevelReaction, e as isLevelWatch, r as reactionDurationMs, f as reactionRateBucketKey, p as runReaction };
@@ -1,4 +1,4 @@
1
- //#region src/reactiveConfig.ts
1
+ // src/reactiveConfig.ts
2
2
  var e = 8, t = 32, n = (e) => {
3
3
  if (e == null || e === "") return;
4
4
  let t = Number(e);
@@ -7,5 +7,4 @@ var e = 8, t = 32, n = (e) => {
7
7
  deliveryConcurrency: n(t.VOLTRO_REACTIVE_DELIVERY_CONCURRENCY) ?? n(e?.deliveryConcurrency) ?? 8,
8
8
  rawReadTrackingLimit: n(t.VOLTRO_RAW_READ_TRACKING_LIMIT) ?? n(e?.rawReadTrackingLimit) ?? 32
9
9
  });
10
- //#endregion
11
10
  export { e as DEFAULT_DELIVERY_CONCURRENCY, t as DEFAULT_RAW_READ_TRACKING_LIMIT, r as resolveReactiveConfig };
@@ -1,5 +1,5 @@
1
1
  import { getRelations as e } from "@voltro/database";
2
- //#region src/readClassification.ts
2
+ // src/readClassification.ts
3
3
  var t = (e) => {
4
4
  if (typeof e != "object" || !e) return;
5
5
  let t = e.subquery;
@@ -53,5 +53,4 @@ var t = (e) => {
53
53
  restricting: i
54
54
  };
55
55
  };
56
- //#endregion
57
56
  export { a as classifyRead };
@@ -1,22 +1,23 @@
1
1
  import { classifyRead as e } from "./readClassification.js";
2
- import { Effect as t } from "effect";
3
- import { AsyncLocalStorage as n } from "node:async_hooks";
4
- //#region src/readRecorder.ts
5
- var r = new n(), i, a = /* @__PURE__ */ new Set(), o = (e) => {
6
- i = e, a.clear();
7
- }, s = () => i !== void 0, c = (e, t) => {
8
- if (i === void 0) return;
9
- let n = new Set(t), o = a.has(e) || n.size === 0;
10
- r.enterWith({
2
+ import { noteCacheRead as t } from "./computedQueryCache.js";
3
+ import { Effect as n } from "effect";
4
+ import { AsyncLocalStorage as r } from "node:async_hooks";
5
+ // src/readRecorder.ts
6
+ var i = new r(), a, o = /* @__PURE__ */ new Set(), s = (e) => {
7
+ a = e, o.clear();
8
+ }, c = () => a !== void 0, l = (e, t) => {
9
+ if (a === void 0) return;
10
+ let n = new Set(t), r = o.has(e) || n.size === 0;
11
+ i.enterWith({
11
12
  procedure: e,
12
13
  declared: n,
13
14
  composed: /* @__PURE__ */ new Set(),
14
15
  restricting: /* @__PURE__ */ new Set(),
15
16
  depth: { n: 0 },
16
- ...o ? { muted: !0 } : {}
17
+ ...r ? { muted: !0 } : {}
17
18
  });
18
- }, l = async (e, t, n = []) => {
19
- let i = {
19
+ }, u = async (e, t, n = []) => {
20
+ let r = {
20
21
  procedure: e,
21
22
  declared: new Set(n),
22
23
  composed: /* @__PURE__ */ new Set(),
@@ -24,12 +25,12 @@ var r = new n(), i, a = /* @__PURE__ */ new Set(), o = (e) => {
24
25
  depth: { n: 0 }
25
26
  };
26
27
  return {
27
- result: await r.run(i, t),
28
- composed: i.composed,
29
- restricting: i.restricting
28
+ result: await i.run(r, t),
29
+ composed: r.composed,
30
+ restricting: r.restricting
30
31
  };
31
- }, u = async (e) => {
32
- let t = r.getStore();
32
+ }, d = async (e) => {
33
+ let t = i.getStore();
33
34
  if (t === void 0) return e();
34
35
  t.depth.n += 1;
35
36
  try {
@@ -37,30 +38,29 @@ var r = new n(), i, a = /* @__PURE__ */ new Set(), o = (e) => {
37
38
  } finally {
38
39
  --t.depth.n;
39
40
  }
40
- }, d = (e) => t.suspend(() => {
41
- let n = r.getStore();
42
- return n === void 0 ? e : t.acquireUseRelease(t.sync(() => {
43
- n.depth.n += 1;
44
- }), () => e, () => t.sync(() => {
45
- --n.depth.n;
41
+ }, f = (e) => n.suspend(() => {
42
+ let t = i.getStore();
43
+ return t === void 0 ? e : n.acquireUseRelease(n.sync(() => {
44
+ t.depth.n += 1;
45
+ }), () => e, () => n.sync(() => {
46
+ --t.depth.n;
46
47
  }));
47
- }), f = (t) => {
48
- let n = r.getStore();
48
+ }), p = (t) => {
49
+ let n = i.getStore();
49
50
  if (n === void 0 || n.muted === !0) return;
50
- let { composed: o, restricting: s } = e(t, n.depth.n > 0);
51
- for (let e of o) n.composed.add(e);
51
+ let { composed: r, restricting: s } = e(t, n.depth.n > 0);
52
+ for (let e of r) n.composed.add(e);
52
53
  for (let e of s) n.composed.has(e) || n.restricting.add(e);
53
- if (i === void 0 || a.has(n.procedure)) return;
54
- let c = m(n.procedure, n.composed, n.declared, n.restricting);
55
- c !== void 0 && (a.add(n.procedure), i(c));
56
- }, p = (e) => new Proxy(e, { get(e, t) {
57
- let n = Reflect.get(e, t, e);
58
- return typeof n == "function" && t !== "query" ? n.bind(e) : t !== "query" || typeof n != "function" ? n : (t) => (f(t), n.call(e, t));
59
- } }), m = (e, t, n, r) => {
54
+ if (a === void 0 || o.has(n.procedure)) return;
55
+ let c = h(n.procedure, n.composed, n.declared, n.restricting);
56
+ c !== void 0 && (o.add(n.procedure), a(c));
57
+ }, m = (e) => new Proxy(e, { get(e, n) {
58
+ let r = Reflect.get(e, n, e);
59
+ return typeof r == "function" && n !== "query" ? r.bind(e) : n !== "query" || typeof r != "function" ? r : (n) => (p(n), t(n), r.call(e, n));
60
+ } }), h = (e, t, n, r) => {
60
61
  let i = [...t], a = 0;
61
62
  for (let e of i) n.has(e) || (i[a++] = e);
62
63
  if (i.length = a, i.sort(), i.length !== 0) return `${e}: read ${i.map((e) => `\`${e}\``).join(", ")} without declaring ${i.length === 1 ? "it" : "them"} in \`source:\`.\n A write to ${i.length === 1 ? "that table" : "those tables"} will not re-run this query, so an open view keeps\n showing what it showed before. The write itself is fine, which is why nothing else reports this.
63
64
  Observed on this boot — a branch that did not run contributes nothing, so this names what WAS\n read and never claims the declaration is otherwise complete.` + (r.size > 0 ? `\n Not counted (read only to narrow the result): ${[...r].sort().map((e) => `\`${e}\``).join(", ")}.` : "");
64
65
  };
65
- //#endregion
66
- export { c as enterReadRecording, f as noteRead, s as readRecordingActive, l as recordReads, p as recordingStore, u as restrictingReads, d as restrictingReadsEffect, o as setSourceGapSink, m as sourceGapReport };
66
+ export { l as enterReadRecording, p as noteRead, c as readRecordingActive, u as recordReads, m as recordingStore, d as restrictingReads, f as restrictingReadsEffect, s as setSourceGapSink, h as sourceGapReport };
@@ -0,0 +1,11 @@
1
+ import { and as e } from "@voltro/database";
2
+ // src/readScopePredicate.ts
3
+ var t = (t, n) => {
4
+ let r = t.setOp === void 0 ? t.alias ?? ((t.joins?.length ?? 0) > 0 ? t.table : void 0) : void 0, i = n((e) => r === void 0 ? e : `${r}.${e}`);
5
+ return {
6
+ ...t,
7
+ ...r === void 0 ? {} : { alias: r },
8
+ predicate: t.predicate ? e(t.predicate, i) : i
9
+ };
10
+ };
11
+ export { t as addReadScopePredicate };
package/dist/rebac.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Schema as e } from "effect";
2
- //#region src/rebac.ts
2
+ // src/rebac.ts
3
3
  var t = "admin:full", n = class extends e.TaggedError()("AccessDenied", {
4
4
  action: e.String,
5
5
  resourceType: e.String,
@@ -100,5 +100,4 @@ var t = "admin:full", n = class extends e.TaggedError()("AccessDenied", {
100
100
  let n = new Set(t.map((e) => e.id));
101
101
  return e.filter((e) => !n.has(e.id)).map((e) => e.id);
102
102
  };
103
- //#endregion
104
103
  export { n as AccessDenied, t as REBAC_ADMIN_SCOPE, f as assertCan, d as can, s as clearResourcePolicies, i as defineResourcePolicy, u as effectiveRelations, a as getResourcePolicy, o as listResourcePolicies, c as rebacPolicyGraph, g as revokedIds, h as visibleRows };
@@ -1,7 +1,7 @@
1
1
  import { AccessDenied as e, can as t, getResourcePolicy as n, visibleRows as r } from "./rebac.js";
2
2
  import { Effect as i } from "effect";
3
3
  import { and as a, eq as o, id as s, table as c, text as l, timestamp as u } from "@voltro/database";
4
- //#region src/rebacInterceptor.ts
4
+ // src/rebacInterceptor.ts
5
5
  var d = c("_voltro_rebac_tuples", {
6
6
  id: s({ prefix: "rbct" }),
7
7
  subjectId: l(),
@@ -77,5 +77,4 @@ var d = c("_voltro_rebac_tuples", {
77
77
  });
78
78
  };
79
79
  };
80
- //#endregion
81
80
  export { d as _voltroRebacTuplesTable, m as buildRebacInterceptor, g as buildRebacReadFilter, f as loadResourceTuples, h as loadSubjectTuples };
package/dist/registry.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Effect as e } from "effect";
2
2
  import { ValidationError as t, ValidationErrors as n, effectiveScopes as r, hasEffectiveScope as i, recheckGuardsEffect as a } from "@voltro/protocol";
3
- //#region src/registry.ts
3
+ // src/registry.ts
4
4
  var o = (t) => ({
5
5
  has: (e) => i(t, e),
6
6
  hasAny: (e) => e.some((e) => i(t, e)),
@@ -25,5 +25,4 @@ var o = (t) => ({
25
25
  ...a === void 0 ? {} : { params: a }
26
26
  }))
27
27
  };
28
- //#endregion
29
28
  export { s as appValidation, o as makeAppAccess };
@@ -1,6 +1,6 @@
1
1
  import { resolveDependentTables as e } from "./dependencyGraph.js";
2
2
  import { getRelations as t, getTable as n, isColumnReference as r } from "@voltro/database";
3
- //#region src/relevantFields.ts
3
+ // src/relevantFields.ts
4
4
  var i = (e) => e.alias !== void 0 || (e.joins?.length ?? 0) > 0 || e.setOp !== void 0 || e.ctes !== void 0 && e.ctes.length > 0 || e.aggregations !== void 0 && e.aggregations.some((e) => e.op.startsWith("window-")), a = /* @__PURE__ */ new Set(["*"]), o = (e, t) => {
5
5
  if (e !== void 0) {
6
6
  if ("not" in e) o(e.not, t);
@@ -61,5 +61,4 @@ var i = (e) => e.alias !== void 0 || (e.joins?.length ?? 0) > 0 || e.setOp !== v
61
61
  for (let e of r) if (n.has(e)) return !0;
62
62
  return !1;
63
63
  };
64
- //#endregion
65
64
  export { a as ALL_COLUMNS, f as isEventRelevant, d as mutatedColumns, u as resolveRelevantFields };