@voltro/runtime 0.85.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.
- package/CHANGELOG.md +5987 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.md +864 -253
- package/dist/aggregate.js +42 -0
- package/dist/aggregateExtrema.js +80 -0
- package/dist/aggregateIvm.js +115 -0
- package/dist/analyticsMirror.js +228 -0
- package/dist/analyticsSink.js +32 -0
- package/dist/apiKeyUsage.js +33 -0
- package/dist/apiKeys.js +227 -0
- package/dist/apiKeysWiring.js +114 -0
- package/dist/apiRoleBucketSampler.js +64 -0
- package/dist/apiRoleWorkloadHistory.js +56 -0
- package/dist/apiRoleWorkloadMetrics.js +78 -0
- package/dist/apiRoleWorkloadStorage.js +95 -0
- package/dist/approvalBuiltins.js +10 -0
- package/dist/approvals.js +262 -0
- package/dist/authMiddlewareLayer.js +48 -0
- package/dist/bindEvent.js +92 -0
- package/dist/bootListener.js +143 -0
- package/dist/bootRefusal.js +7 -0
- package/dist/bootStoreCodec.js +71 -0
- package/dist/businessRules.js +67 -0
- package/dist/changeClaimsTable.js +12 -0
- package/dist/circuitBreaker.js +1 -0
- package/dist/columnOnUpdate.js +23 -0
- package/dist/composeAnalytics.js +129 -0
- package/dist/computedQuery.js +4 -0
- package/dist/computedQueryCache.js +231 -0
- package/dist/connectionBuiltins.js +81 -0
- package/dist/connectionCredentials.js +66 -0
- package/dist/connectionState.js +34 -0
- package/dist/connectionVault.js +410 -0
- package/dist/connectionsFacade.js +56 -0
- package/dist/coordinatedSchedule.js +145 -0
- package/dist/crdtHistory.js +138 -0
- package/dist/crdtMerge.js +179 -0
- package/dist/crdtVersionsTable.js +25 -0
- package/dist/credentialBound.js +12 -0
- package/dist/crud.js +72 -0
- package/dist/dataStore.js +712 -0
- package/dist/dataloader.js +61 -0
- package/dist/declaredTablesGuard.js +49 -0
- package/dist/defineExecutor.js +4 -0
- package/dist/dependencyGraph.js +32 -0
- package/dist/devices.js +228 -0
- package/dist/devicesWiring.js +168 -0
- package/dist/dialectReplicationAdapter.js +29 -0
- package/dist/dispatcher.js +522 -0
- package/dist/effectStore.js +71 -0
- package/dist/engineClients.js +24 -0
- package/dist/eventBus.js +260 -0
- package/dist/eventPublish.js +49 -0
- package/dist/events.js +193 -0
- package/dist/expectation.js +52 -0
- package/dist/expectationEvaluator.js +308 -0
- package/dist/experiment.js +96 -0
- package/dist/experimentEvaluator.js +245 -0
- package/dist/externalizedTasks.js +38 -0
- package/dist/fieldCipher.js +130 -0
- package/dist/fieldKeyRegistry.js +295 -0
- package/dist/fieldKeyRekey.js +286 -0
- package/dist/fieldKeyScan.js +136 -0
- package/dist/fieldKeyring.js +77 -0
- package/dist/fingerprint.js +21 -0
- package/dist/finops.js +42 -0
- package/dist/finopsAccountant.js +216 -0
- package/dist/handlerBody.js +8 -0
- package/dist/healthProbes.js +55 -0
- package/dist/hot.d.ts +56 -0
- package/dist/hot.js +3 -0
- package/dist/hotDataStore.js +148 -0
- package/dist/hotDataStoreSnapshot.js +98 -0
- package/dist/hotDataStoreTables.js +18 -0
- package/dist/http-range.d.ts +53 -0
- package/dist/http-range.js +52 -0
- package/dist/httpClientSsrf.js +24 -0
- package/dist/httpClientTracing.js +14 -0
- package/dist/httpCompression.js +76 -0
- package/dist/httpInputStream.js +82 -0
- package/dist/httpKeepAlive.js +12 -0
- package/dist/httpRouteMounts.js +48 -0
- package/dist/idempotencyStore.js +110 -0
- package/dist/idleDetector.js +21 -0
- package/dist/index.d.ts +1249 -517
- package/dist/index.js +155 -15292
- package/dist/insertRequiredColumns.js +19 -0
- package/dist/inspectWorkflow.js +1 -0
- package/dist/instanceMembership.js +98 -0
- package/dist/ivm.js +125 -0
- package/dist/kvDataStore.js +86 -0
- package/dist/kvFacade.js +38 -0
- package/dist/matcher.js +304 -0
- package/dist/memoryColumnDefaults.js +11 -0
- package/dist/memoryQueryJoins.js +114 -0
- package/dist/memorySetOperations.js +43 -0
- package/dist/metrics.js +175 -0
- package/dist/observability.js +123 -0
- package/dist/observedGraph.js +52 -0
- package/dist/originGuard.js +116 -0
- package/dist/outbox.js +352 -0
- package/dist/pluginRefRules.js +65 -0
- package/dist/policyGuardResolver.js +55 -0
- package/dist/preview.js +62 -0
- package/dist/projectedRows.js +12 -0
- package/dist/provenance.js +63 -0
- package/dist/rangeIndex.js +89 -0
- package/dist/rawReadScope.js +17 -0
- package/dist/reaction.js +85 -0
- package/dist/reactiveConfig.js +11 -0
- package/dist/readClassification.js +57 -0
- package/dist/readRecorder.js +67 -0
- package/dist/readScopePredicate.js +12 -0
- package/dist/rebac.js +104 -0
- package/dist/rebacInterceptor.js +81 -0
- package/dist/registry.js +29 -0
- package/dist/relevantFields.js +65 -0
- package/dist/replicaHealth.js +42 -0
- package/dist/replicaLocality.js +44 -0
- package/dist/replicaObservations.js +121 -0
- package/dist/replicaSelection.js +32 -0
- package/dist/replicatedDataStore.js +257 -0
- package/dist/requestLoader.js +7 -0
- package/dist/resumeCensus.js +28 -0
- package/dist/revalidation.js +22 -0
- package/dist/rowFilter.js +82 -0
- package/dist/rowStateBytes.js +45 -0
- package/dist/rpcBodyCap.js +63 -0
- package/dist/rpcConnections.js +83 -0
- package/dist/rpcDefectDiagnostics.js +15 -0
- package/dist/rpcServer.js +1065 -0
- package/dist/rpcWorkloadAdmission.js +50 -0
- package/dist/runAsSystem.js +23 -0
- package/dist/rywPositionStore.js +119 -0
- package/dist/schedule.js +23 -0
- package/dist/scheduleBackfillRequests.js +151 -0
- package/dist/scheduleClaimsTable.js +11 -0
- package/dist/scheduleRunsTable.js +37 -0
- package/dist/scheduler.js +840 -0
- package/dist/schemaRegistry.js +65 -0
- package/dist/secretsResolver.js +35 -0
- package/dist/securityHeaders.js +33 -0
- package/dist/servePipeline.js +374 -0
- package/dist/serverOnlyAudit.js +66 -0
- package/dist/serverTracer.js +15 -0
- package/dist/serviceCredentials.js +40 -0
- package/dist/setReadScopes.js +28 -0
- package/dist/singleNodeOrchestrator.js +91 -0
- package/dist/snapshotValueCodec.js +46 -0
- package/dist/sourceResolution.js +52 -0
- package/dist/storeMiddleware.js +882 -0
- package/dist/storeQuery.js +204 -0
- package/dist/storeRead.js +10 -0
- package/dist/subscriber.js +8 -0
- package/dist/subscriptionOutbox.js +139 -0
- package/dist/subscriptionRegistry.js +82 -0
- package/dist/subscriptionResume.js +132 -0
- package/dist/subscriptionSocketMetrics.js +65 -0
- package/dist/systemSubject.js +5 -0
- package/dist/tenantScope.js +11 -0
- package/dist/tenantSelection.js +27 -0
- package/dist/timeline.js +105 -0
- package/dist/traceContext.js +5 -0
- package/dist/traceSink.js +63 -0
- package/dist/traceSpansTable.js +29 -0
- package/dist/traceparent.js +23 -0
- package/dist/transactionSubject.js +12 -0
- package/dist/trustedProxy.js +155 -0
- package/dist/undo.js +129 -0
- package/dist/undoBuiltins.js +69 -0
- package/dist/undoCapture.js +74 -0
- package/dist/undoLogTable.js +16 -0
- package/dist/upsertBinding.js +20 -0
- package/dist/wakeOrchestrator.js +34 -0
- package/dist/wakeRegistry.js +71 -0
- package/dist/wakeRouter.js +63 -0
- package/dist/wakeSupervisor.js +62 -0
- package/dist/wakeupsTable.js +12 -0
- package/dist/webSocketGatewayRuntime.js +154 -0
- package/dist/webhookVerification.js +18 -0
- package/dist/wireColumnStrip.js +84 -0
- package/dist/workflowReadBuiltins.js +87 -0
- package/dist/workflowRuntime.js +708 -0
- package/package.json +19 -7
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { pruneWakeups as e } from "./wakeRegistry.js";
|
|
2
|
+
import { wakeDueOnce as t } from "./wakeOrchestrator.js";
|
|
3
|
+
import { makeProcessAdapter as n } from "./wakeSupervisor.js";
|
|
4
|
+
import { isIdleNow as r, makeIdleGate as i } from "./idleDetector.js";
|
|
5
|
+
import { makeRouterActivity as a, makeWakeProxyServer as o } from "./wakeRouter.js";
|
|
6
|
+
//#region src/singleNodeOrchestrator.ts
|
|
7
|
+
var s = async (e) => {
|
|
8
|
+
try {
|
|
9
|
+
return (await e.query({
|
|
10
|
+
table: "_voltro_workflow_runs",
|
|
11
|
+
predicate: {
|
|
12
|
+
column: "status",
|
|
13
|
+
op: "eq",
|
|
14
|
+
value: "running"
|
|
15
|
+
},
|
|
16
|
+
order: [],
|
|
17
|
+
take: void 0,
|
|
18
|
+
skip: void 0,
|
|
19
|
+
projection: ["id"]
|
|
20
|
+
})).length;
|
|
21
|
+
} catch {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
}, c = async (e) => {
|
|
25
|
+
let i = n(e.supervisor), a = await t({
|
|
26
|
+
store: e.store,
|
|
27
|
+
adapter: i,
|
|
28
|
+
...e.now === void 0 ? {} : { now: e.now },
|
|
29
|
+
...e.log === void 0 ? {} : { log: e.log }
|
|
30
|
+
});
|
|
31
|
+
a > 0 && e.idleGate.reset();
|
|
32
|
+
let o = await r({
|
|
33
|
+
store: e.store,
|
|
34
|
+
signals: e.signals,
|
|
35
|
+
...e.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: e.wakeLookaheadMs },
|
|
36
|
+
...e.now === void 0 ? {} : { now: e.now }
|
|
37
|
+
}), s = !1;
|
|
38
|
+
return e.idleGate.update(o) && e.supervisor.isRunning() && (e.log?.info("orchestrator: idle grace elapsed — scaling app to zero"), await e.supervisor.stop(), e.idleGate.reset(), s = !0), {
|
|
39
|
+
woke: a,
|
|
40
|
+
stopped: s
|
|
41
|
+
};
|
|
42
|
+
}, l = async (t) => {
|
|
43
|
+
let n = i(t.idleGraceMs ?? 6e4), r = t.tickMs ?? 1e3, l = a(), u = 0, d = t.signals === void 0, f = t.signals ?? {
|
|
44
|
+
connectedClients: () => l.openConnections(),
|
|
45
|
+
inFlightRequests: () => l.inFlightRequests(),
|
|
46
|
+
activeWorkflowExecutions: () => u
|
|
47
|
+
}, p = o({
|
|
48
|
+
supervisor: t.supervisor,
|
|
49
|
+
targetHost: t.targetHost,
|
|
50
|
+
targetPort: t.targetPort,
|
|
51
|
+
onActivity: () => {
|
|
52
|
+
n.reset();
|
|
53
|
+
},
|
|
54
|
+
activity: l,
|
|
55
|
+
...t.log === void 0 ? {} : { log: t.log }
|
|
56
|
+
}), m = await new Promise((e, n) => {
|
|
57
|
+
p.once("error", n), p.listen(t.publicPort, t.publicHost ?? "0.0.0.0", () => {
|
|
58
|
+
let n = p.address();
|
|
59
|
+
e(typeof n == "object" && n ? n.port : t.publicPort);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
t.log?.info("orchestrator: router listening", { port: m });
|
|
63
|
+
let h = !1, g, _ = t.firedRetentionMs ?? 6e5, v = 0, y = async () => {
|
|
64
|
+
if (!h) {
|
|
65
|
+
try {
|
|
66
|
+
if (d && (u = await s(t.store)), await c({
|
|
67
|
+
store: t.store,
|
|
68
|
+
supervisor: t.supervisor,
|
|
69
|
+
signals: f,
|
|
70
|
+
idleGate: n,
|
|
71
|
+
...t.wakeLookaheadMs === void 0 ? {} : { wakeLookaheadMs: t.wakeLookaheadMs },
|
|
72
|
+
...t.log === void 0 ? {} : { log: t.log }
|
|
73
|
+
}), v++ % 60 == 0) {
|
|
74
|
+
let n = await e(t.store, { firedOlderThan: new Date(Date.now() - _) });
|
|
75
|
+
n > 0 && t.log?.info("orchestrator: pruned fired wakeups", { count: n });
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
t.log?.warn("orchestrator: tick failed", { reason: e instanceof Error ? e.message : String(e) });
|
|
79
|
+
}
|
|
80
|
+
h || (g = setTimeout(() => void y(), r));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return y(), {
|
|
84
|
+
port: m,
|
|
85
|
+
stop: async () => {
|
|
86
|
+
h = !0, g !== void 0 && clearTimeout(g), await new Promise((e) => p.close(() => e()));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { s as countRunningWorkflows, c as runOrchestratorTick, l as runSingleNodeOrchestrator };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/snapshotValueCodec.ts
|
|
2
|
+
var e = "\0", t = `${e}d`, n = `${e}n`, r = `${e}b`, i = `${e}o`, a = 1, o = (e) => {
|
|
3
|
+
if (typeof e != "object" || !e) return !1;
|
|
4
|
+
let t = Object.getPrototypeOf(e);
|
|
5
|
+
return t === Object.prototype || t === null;
|
|
6
|
+
}, s = (a) => {
|
|
7
|
+
if (typeof a != "object" || !a) return typeof a == "bigint" ? { [n]: a.toString() } : a;
|
|
8
|
+
if (a instanceof Date) return { [t]: Number.isNaN(a.getTime()) ? null : a.toISOString() };
|
|
9
|
+
if (a instanceof Uint8Array) return { [r]: Buffer.from(a.buffer, a.byteOffset, a.byteLength).toString("base64") };
|
|
10
|
+
if (Array.isArray(a)) return a.map(s);
|
|
11
|
+
if (o(a)) {
|
|
12
|
+
let t = {}, n = !1;
|
|
13
|
+
for (let [r, i] of Object.entries(a)) r.startsWith(e) && (n = !0), t[r] = s(i);
|
|
14
|
+
return n ? { [i]: t } : t;
|
|
15
|
+
}
|
|
16
|
+
throw TypeError("A snapshot value carries a non-plain object; it cannot be cached faithfully.");
|
|
17
|
+
}, c = (e) => {
|
|
18
|
+
if (typeof e != "object" || !e) return e;
|
|
19
|
+
if (Array.isArray(e)) return e.map(c);
|
|
20
|
+
let a = e, o = Object.keys(a);
|
|
21
|
+
if (o.length === 1) {
|
|
22
|
+
let e = o[0], s = a[e];
|
|
23
|
+
if (e === t) return s === null ? /* @__PURE__ */ new Date(NaN) : new Date(s);
|
|
24
|
+
if (e === n) return BigInt(s);
|
|
25
|
+
if (e === r) return new Uint8Array(Buffer.from(s, "base64"));
|
|
26
|
+
if (e === i) {
|
|
27
|
+
let e = {};
|
|
28
|
+
for (let [t, n] of Object.entries(s)) e[t] = c(n);
|
|
29
|
+
return e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let s = {};
|
|
33
|
+
for (let [e, t] of Object.entries(a)) s[e] = c(t);
|
|
34
|
+
return s;
|
|
35
|
+
}, l = (e) => ({
|
|
36
|
+
v: a,
|
|
37
|
+
value: s(e)
|
|
38
|
+
}), u = (e) => {
|
|
39
|
+
if (o(e) && e.v === a && "value" in e) try {
|
|
40
|
+
return { value: c(e.value) };
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { u as decodeSnapshotValue, l as encodeSnapshotValue };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { captureOptionalQuerySources as e, declaredReactivityChannelKeys as t, isReactivityChannelKey as n, sourceKeys as r } from "@voltro/protocol";
|
|
2
|
+
//#region src/sourceResolution.ts
|
|
3
|
+
var i = (e, t) => {
|
|
4
|
+
let n, r = 0;
|
|
5
|
+
for (let i of t) {
|
|
6
|
+
let t = 0;
|
|
7
|
+
for (; t < e.length && t < i.length && e[t] === i[t];) t++;
|
|
8
|
+
let a = 0;
|
|
9
|
+
for (; a < e.length - t && a < i.length - t && e[e.length - 1 - a] === i[i.length - 1 - a];) a++;
|
|
10
|
+
let o = (t + a) / Math.max(e.length, i.length);
|
|
11
|
+
o > r && o >= .6 && (r = o, n = i);
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}, a = (a, o) => {
|
|
15
|
+
let s = t(), c = [], l = /* @__PURE__ */ new Map();
|
|
16
|
+
for (let t of a) {
|
|
17
|
+
let a = new Set(e(t.name, t.source, t.optionalSource));
|
|
18
|
+
for (let e of r(t.source)) if (n(e)) {
|
|
19
|
+
if (s.has(e)) continue;
|
|
20
|
+
c.push({
|
|
21
|
+
procedure: t.name,
|
|
22
|
+
source: e,
|
|
23
|
+
didYouMean: void 0,
|
|
24
|
+
channel: !0,
|
|
25
|
+
...a.has(e) ? { optional: !0 } : {}
|
|
26
|
+
});
|
|
27
|
+
} else o.size === 0 || o.has(e) || (l.has(e) || l.set(e, i(e, o)), c.push({
|
|
28
|
+
procedure: t.name,
|
|
29
|
+
source: e,
|
|
30
|
+
didYouMean: a.has(e) ? void 0 : l.get(e),
|
|
31
|
+
channel: !1,
|
|
32
|
+
...a.has(e) ? { optional: !0 } : {}
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
return c;
|
|
36
|
+
}, o = (e) => {
|
|
37
|
+
if (e.length === 0) return;
|
|
38
|
+
let t = e.filter((e) => e.optional === !0);
|
|
39
|
+
if (t.length > 0) {
|
|
40
|
+
let n = o(e.filter((e) => e.optional !== !0)), r = t.map((e) => ` ${e.procedure}: optional integration source '${e.source}' is unavailable`);
|
|
41
|
+
return [n, `${t.length} optional integration source(s) are unavailable:\n${r.join("\n")}\nTheir observers remain declared. Installed sources still trigger recomputation; executor authorization still applies.`].filter((e) => e !== void 0).join("\n\n");
|
|
42
|
+
}
|
|
43
|
+
let n = e.map((e) => e.channel ? ` ${e.procedure}: source '${e.source}' names a reactivity channel nobody declared` : ` ${e.procedure}: source '${e.source}' matches no declared table` + (e.didYouMean === void 0 ? "" : ` — did you mean '${e.didYouMean}'?`)), r = e.some((e) => e.channel) ? "\nFor the `channel:` entries: declare it with `reactivityChannel(<name>)` and pass the\nCHANNEL as `source:`, not its key as a string. Authoring against the object is what\nmakes a channel source impossible to leave stale — you cannot import a declaration\nthat does not exist." : "";
|
|
44
|
+
return `${e.length} reactive source(s) name a table that does not exist:\n${n.join("\n")}\n
|
|
45
|
+
These queries are NOT broken. They serve their first snapshot and then never
|
|
46
|
+
update again, which is indistinguishable from "nothing has changed" — so the
|
|
47
|
+
symptom is silence, and silence is what this surface exists to eliminate.
|
|
48
|
+
A \`source:\` is a STRING, so \`tsc\` cannot see a stale one and a rename leaves it
|
|
49
|
+
behind quietly.` + r;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { o as formatUnresolvedSources, a as unresolvedSources };
|