@query-farm/vgi 0.28.0 → 0.29.1
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/README.md +52 -8
- package/dist/arguments/argument-spec.d.ts +57 -2
- package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
- package/dist/arrow/impl-arrowjs/iterate.d.ts +10 -1
- package/dist/arrow/impl-arrowjs/schema.d.ts +2 -0
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/iterate.d.ts +10 -1
- package/dist/arrow/impl-flechette/schema.d.ts +2 -0
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/schema-types.d.ts +3 -1
- package/dist/arrow/types.d.ts +39 -3
- package/dist/catalog/composite.d.ts +13 -13
- package/dist/catalog/descriptors.d.ts +7 -3
- package/dist/catalog/interface.d.ts +108 -38
- package/dist/catalog/read-only.d.ts +32 -15
- package/dist/client/client.d.ts +37 -30
- package/dist/client/types.d.ts +2 -0
- package/dist/client-entry.d.ts +1 -1
- package/dist/client-entry.js +791 -447
- package/dist/client-entry.js.map +18 -17
- package/dist/filter-pushdown/capabilities.d.ts +3 -0
- package/dist/filter-pushdown/deserialize.d.ts +14 -15
- package/dist/filter-pushdown/evaluate.d.ts +14 -44
- package/dist/filter-pushdown/index.d.ts +2 -2
- package/dist/filter-pushdown/types.d.ts +120 -68
- package/dist/functions/aggregate.d.ts +4 -0
- package/dist/functions/registry.d.ts +5 -5
- package/dist/functions/scalar.d.ts +6 -1
- package/dist/functions/table-buffering.d.ts +9 -0
- package/dist/functions/table-in-out.d.ts +13 -0
- package/dist/functions/table.d.ts +72 -2
- package/dist/functions/types.d.ts +60 -2
- package/dist/generated/vgi-client.d.ts +114 -26
- package/dist/generated/vgi-protocol-schemas.d.ts +34 -0
- package/dist/http/fetch.d.ts +16 -0
- package/dist/index.core.d.ts +4 -3
- package/dist/index.js +3396 -2064
- package/dist/index.js.map +55 -49
- package/dist/metadata/types.d.ts +15 -2
- package/dist/protocol/handlers/catalog/shared.d.ts +0 -8
- package/dist/protocol/handlers/function.d.ts +11 -0
- package/dist/protocol/handlers/shared.d.ts +3 -1
- package/dist/protocol/serializers/bind.d.ts +1 -2
- package/dist/protocol/serializers/cardinality.d.ts +1 -2
- package/dist/protocol/serializers/splits.d.ts +126 -0
- package/dist/protocol/types.d.ts +36 -3
- package/dist/request-auth.d.ts +28 -0
- package/dist/schema-path.d.ts +7 -0
- package/dist/serve-entry.d.ts +25 -0
- package/dist/serve-entry.js +1129 -569
- package/dist/serve-entry.js.map +36 -32
- package/dist/split-token.d.ts +88 -0
- package/dist/types.d.ts +8 -0
- package/dist/worker-cf-entry.js +2928 -1689
- package/dist/worker-cf-entry.js.map +51 -44
- package/dist/worker.d.ts +1 -1
- package/package.json +3 -3
- package/src/arguments/argument-spec.ts +93 -4
- package/src/arguments/arguments.ts +0 -1
- package/src/arrow/impl-arrowjs/index.ts +1 -1
- package/src/arrow/impl-arrowjs/iterate.ts +21 -0
- package/src/arrow/impl-arrowjs/schema.ts +4 -0
- package/src/arrow/impl-flechette/index.ts +1 -1
- package/src/arrow/impl-flechette/iterate.ts +24 -1
- package/src/arrow/impl-flechette/schema.ts +4 -0
- package/src/arrow/index.ts +1 -1
- package/src/arrow/schema-types.ts +4 -0
- package/src/arrow/types.ts +39 -3
- package/src/catalog/composite.ts +26 -26
- package/src/catalog/descriptors.ts +12 -3
- package/src/catalog/interface.ts +217 -72
- package/src/catalog/read-only.ts +141 -84
- package/src/client/client.ts +97 -73
- package/src/client/types.ts +2 -0
- package/src/client-entry.ts +2 -1
- package/src/filter-pushdown/capabilities.ts +13 -0
- package/src/filter-pushdown/collector.ts +22 -35
- package/src/filter-pushdown/deserialize.ts +657 -221
- package/src/filter-pushdown/evaluate.ts +410 -499
- package/src/filter-pushdown/index.ts +16 -2
- package/src/filter-pushdown/types.ts +88 -71
- package/src/functions/aggregate.ts +12 -1
- package/src/functions/copy-from.ts +2 -1
- package/src/functions/copy-to.ts +2 -1
- package/src/functions/registry.ts +24 -22
- package/src/functions/scalar.ts +37 -0
- package/src/functions/table-buffering.ts +48 -6
- package/src/functions/table-in-out.ts +194 -33
- package/src/functions/table.ts +187 -22
- package/src/functions/types.ts +64 -1
- package/src/generated/vgi-client.ts +122 -28
- package/src/generated/vgi-protocol-schemas.ts +455 -58
- package/src/http/fetch.ts +129 -2
- package/src/index.core.ts +4 -2
- package/src/metadata/resolve.ts +43 -1
- package/src/metadata/serialize.ts +43 -5
- package/src/metadata/types.ts +17 -1
- package/src/protocol/dispatch.ts +1 -1
- package/src/protocol/handlers/aggregate.ts +23 -12
- package/src/protocol/handlers/catalog/admin.ts +47 -54
- package/src/protocol/handlers/catalog/index_methods.ts +6 -13
- package/src/protocol/handlers/catalog/macro.ts +12 -20
- package/src/protocol/handlers/catalog/shared.ts +12 -57
- package/src/protocol/handlers/catalog/table.ts +49 -112
- package/src/protocol/handlers/catalog/view.ts +18 -22
- package/src/protocol/handlers/function.ts +311 -18
- package/src/protocol/handlers/shared.ts +12 -3
- package/src/protocol/handlers/table-buffering.ts +11 -8
- package/src/protocol/serializers/bind.ts +69 -67
- package/src/protocol/serializers/cardinality.ts +7 -7
- package/src/protocol/serializers/init.ts +52 -10
- package/src/protocol/serializers/splits.ts +221 -0
- package/src/protocol/state-serializer.ts +55 -1
- package/src/protocol/types.ts +36 -3
- package/src/request-auth.ts +73 -0
- package/src/schema-path.ts +25 -0
- package/src/serve-entry.ts +69 -2
- package/src/split-token.ts +297 -0
- package/src/types.ts +9 -0
- package/src/worker-cf-entry.ts +2 -1
- package/src/worker.ts +79 -14
package/src/worker.ts
CHANGED
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
2
|
// VGI Worker: main entry point for running a VGI function server.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
VgiRpcServer,
|
|
6
|
+
observePeerIdentity,
|
|
7
|
+
peerIdentityPrimary,
|
|
8
|
+
serveUnix,
|
|
9
|
+
serveTcp,
|
|
10
|
+
serveStream as serveStreamRpc,
|
|
11
|
+
} from "@query-farm/vgi-rpc";
|
|
5
12
|
import { FunctionRegistry } from "./functions/registry.js";
|
|
6
13
|
import type { VgiFunction } from "./functions/types.js";
|
|
7
14
|
import { buildVgiProtocol } from "./protocol/dispatch.js";
|
|
8
15
|
import type { Protocol } from "@query-farm/vgi-rpc";
|
|
9
|
-
import type
|
|
16
|
+
import { schemaDescriptorPath, type CatalogDescriptor } from "./catalog/descriptors.js";
|
|
10
17
|
import type { CatalogInterface } from "./catalog/interface.js";
|
|
11
18
|
import { ReadOnlyCatalogInterface } from "./catalog/read-only.js";
|
|
12
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Startup/lifecycle tracing, off unless `VGI_DEBUG` is set to something other
|
|
22
|
+
* than "" or "0".
|
|
23
|
+
*
|
|
24
|
+
* These lines used to be unconditional, which put three of them in the log of
|
|
25
|
+
* every worker anyone ever deployed. They are genuinely useful when an ATTACH
|
|
26
|
+
* hangs and you need to know how far startup got, so they are kept rather than
|
|
27
|
+
* deleted — just behind a flag. Errors are NOT gated: `Worker error:` and
|
|
28
|
+
* `Worker init error:` always print.
|
|
29
|
+
*
|
|
30
|
+
* The message is a thunk so an unset flag costs no interpolation.
|
|
31
|
+
*
|
|
32
|
+
* stderr, never stdout: on the stdio transport stdout is the protocol.
|
|
33
|
+
*/
|
|
34
|
+
function debug(message: () => string): void {
|
|
35
|
+
const flag = process.env.VGI_DEBUG;
|
|
36
|
+
if (flag === undefined || flag === "" || flag === "0") return;
|
|
37
|
+
process.stderr.write(message() + "\n");
|
|
38
|
+
}
|
|
39
|
+
|
|
13
40
|
// argv parser for the launcher's `--unix PATH` / `--tcp [HOST:]PORT` /
|
|
14
41
|
// `--idle-timeout SEC` contract. The C++ launcher (vgi extension) appends
|
|
15
42
|
// these to the worker's argv whenever LOCATION uses the `launch:` scheme.
|
|
@@ -21,6 +48,10 @@ interface LauncherArgs {
|
|
|
21
48
|
/** TCP bind port; present iff `--tcp` was passed. */
|
|
22
49
|
tcpPort?: number;
|
|
23
50
|
idleTimeout?: number;
|
|
51
|
+
irohRawUpstream?: boolean;
|
|
52
|
+
irohIssuer?: string;
|
|
53
|
+
irohTrustedProxyAddresses: string[];
|
|
54
|
+
irohAuthenticate: boolean;
|
|
24
55
|
}
|
|
25
56
|
|
|
26
57
|
// Parse a `[HOST:]PORT` --tcp bind spec into a LauncherArgs. A bare PORT (no
|
|
@@ -38,7 +69,7 @@ function parseTcpSpec(spec: string, out: LauncherArgs): void {
|
|
|
38
69
|
}
|
|
39
70
|
|
|
40
71
|
function parseLauncherArgs(argv: readonly string[]): LauncherArgs {
|
|
41
|
-
const out: LauncherArgs = {};
|
|
72
|
+
const out: LauncherArgs = { irohTrustedProxyAddresses: [], irohAuthenticate: true };
|
|
42
73
|
for (let i = 0; i < argv.length; i++) {
|
|
43
74
|
const a = argv[i];
|
|
44
75
|
if (a === "--unix" && i + 1 < argv.length) {
|
|
@@ -53,6 +84,22 @@ function parseLauncherArgs(argv: readonly string[]): LauncherArgs {
|
|
|
53
84
|
out.idleTimeout = Number(argv[++i]);
|
|
54
85
|
} else if (a.startsWith("--idle-timeout=")) {
|
|
55
86
|
out.idleTimeout = Number(a.slice("--idle-timeout=".length));
|
|
87
|
+
} else if (a === "--iroh-raw-upstream" && i + 1 < argv.length) {
|
|
88
|
+
parseTcpSpec(argv[++i], out);
|
|
89
|
+
out.irohRawUpstream = true;
|
|
90
|
+
} else if (a.startsWith("--iroh-raw-upstream=")) {
|
|
91
|
+
parseTcpSpec(a.slice("--iroh-raw-upstream=".length), out);
|
|
92
|
+
out.irohRawUpstream = true;
|
|
93
|
+
} else if (a === "--iroh-issuer" && i + 1 < argv.length) {
|
|
94
|
+
out.irohIssuer = argv[++i];
|
|
95
|
+
} else if (a.startsWith("--iroh-issuer=")) {
|
|
96
|
+
out.irohIssuer = a.slice("--iroh-issuer=".length);
|
|
97
|
+
} else if (a === "--iroh-trusted-proxy" && i + 1 < argv.length) {
|
|
98
|
+
out.irohTrustedProxyAddresses.push(...argv[++i].split(",").filter(Boolean));
|
|
99
|
+
} else if (a.startsWith("--iroh-trusted-proxy=")) {
|
|
100
|
+
out.irohTrustedProxyAddresses.push(...a.slice("--iroh-trusted-proxy=".length).split(",").filter(Boolean));
|
|
101
|
+
} else if (a === "--iroh-observe") {
|
|
102
|
+
out.irohAuthenticate = false;
|
|
56
103
|
}
|
|
57
104
|
}
|
|
58
105
|
return out;
|
|
@@ -102,7 +149,7 @@ export class Worker {
|
|
|
102
149
|
this._registry.register(func);
|
|
103
150
|
// Also index by owning schema + catalog so a schema-qualified bind
|
|
104
151
|
// resolves when one name is declared in more than one schema.
|
|
105
|
-
this._registry.registerInSchema(func, schema
|
|
152
|
+
this._registry.registerInSchema(func, schemaDescriptorPath(schema), config.catalog.name);
|
|
106
153
|
}
|
|
107
154
|
}
|
|
108
155
|
}
|
|
@@ -123,12 +170,18 @@ export class Worker {
|
|
|
123
170
|
}
|
|
124
171
|
|
|
125
172
|
run(argv: readonly string[] = process.argv.slice(2)): void {
|
|
126
|
-
|
|
173
|
+
debug(() => `[worker] starting, pid=${process.pid}`);
|
|
127
174
|
try {
|
|
128
175
|
const protocol = this.buildProtocol();
|
|
129
|
-
|
|
176
|
+
debug(() => `[worker] protocol built`);
|
|
130
177
|
|
|
131
178
|
const launcher = parseLauncherArgs(argv);
|
|
179
|
+
if (launcher.irohRawUpstream) {
|
|
180
|
+
if (!launcher.irohIssuer) throw new TypeError("--iroh-raw-upstream requires --iroh-issuer");
|
|
181
|
+
if (!["127.0.0.1", "::1", "localhost"].includes(launcher.tcpHost ?? "")) {
|
|
182
|
+
throw new TypeError("--iroh-raw-upstream must bind loopback");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
132
185
|
if (launcher.unixPath !== undefined) {
|
|
133
186
|
// VGI_WORKER_IDLE_TIMEOUT overrides whatever the C++ launcher
|
|
134
187
|
// appended via --idle-timeout. Useful in test setups where the
|
|
@@ -139,14 +192,14 @@ export class Worker {
|
|
|
139
192
|
const idleTimeout = envOverride !== undefined && envOverride !== ""
|
|
140
193
|
? Number(envOverride)
|
|
141
194
|
: launcher.idleTimeout;
|
|
142
|
-
|
|
143
|
-
`[worker] AF_UNIX mode: ${launcher.unixPath} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}
|
|
195
|
+
debug(() =>
|
|
196
|
+
`[worker] AF_UNIX mode: ${launcher.unixPath} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}`,
|
|
144
197
|
);
|
|
145
198
|
serveUnix(protocol, {
|
|
146
199
|
unixPath: launcher.unixPath,
|
|
147
200
|
idleTimeout,
|
|
148
201
|
}).then((handle) => handle.done).then(() => {
|
|
149
|
-
|
|
202
|
+
debug(() => `[worker] serveUnix done (idle shutdown)`);
|
|
150
203
|
}).catch((err: any) => {
|
|
151
204
|
process.stderr.write(`Worker error: ${err.message}\n${err.stack}\n`);
|
|
152
205
|
process.exit(1);
|
|
@@ -164,15 +217,27 @@ export class Worker {
|
|
|
164
217
|
const idleTimeout = envOverride !== undefined && envOverride !== ""
|
|
165
218
|
? Number(envOverride)
|
|
166
219
|
: launcher.idleTimeout;
|
|
167
|
-
|
|
168
|
-
`[worker] TCP mode: ${launcher.tcpHost}:${launcher.tcpPort} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}
|
|
220
|
+
debug(() =>
|
|
221
|
+
`[worker] TCP mode: ${launcher.tcpHost}:${launcher.tcpPort} idle=${idleTimeout ?? 300}s${envOverride !== undefined && envOverride !== "" ? " (env override)" : ""}`,
|
|
169
222
|
);
|
|
170
223
|
serveTcp(protocol, {
|
|
171
224
|
host: launcher.tcpHost,
|
|
172
225
|
port: launcher.tcpPort,
|
|
173
226
|
idleTimeout,
|
|
227
|
+
...(launcher.irohRawUpstream
|
|
228
|
+
? {
|
|
229
|
+
proxyProtocolV2Required: true,
|
|
230
|
+
trustedProxyAddresses: launcher.irohTrustedProxyAddresses.length > 0
|
|
231
|
+
? launcher.irohTrustedProxyAddresses
|
|
232
|
+
: ["127.0.0.1"],
|
|
233
|
+
irohProxyIssuer: launcher.irohIssuer,
|
|
234
|
+
peerAuthenticationPolicy: launcher.irohAuthenticate
|
|
235
|
+
? peerIdentityPrimary("iroh")
|
|
236
|
+
: observePeerIdentity,
|
|
237
|
+
}
|
|
238
|
+
: {}),
|
|
174
239
|
}).then((handle) => handle.done).then(() => {
|
|
175
|
-
|
|
240
|
+
debug(() => `[worker] serveTcp done (idle shutdown)`);
|
|
176
241
|
}).catch((err: any) => {
|
|
177
242
|
process.stderr.write(`Worker error: ${err.message}\n${err.stack}\n`);
|
|
178
243
|
process.exit(1);
|
|
@@ -181,9 +246,9 @@ export class Worker {
|
|
|
181
246
|
}
|
|
182
247
|
|
|
183
248
|
const server = new VgiRpcServer(protocol);
|
|
184
|
-
|
|
249
|
+
debug(() => `[worker] server created, calling run()`);
|
|
185
250
|
server.run().then(() => {
|
|
186
|
-
|
|
251
|
+
debug(() => `[worker] server.run() resolved cleanly`);
|
|
187
252
|
}).catch((err) => {
|
|
188
253
|
process.stderr.write(`Worker error: ${err.message}\n${err.stack}\n`);
|
|
189
254
|
process.exit(1);
|