@query-farm/vgi 0.45.0 → 0.47.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 (102) hide show
  1. package/README.md +19 -6
  2. package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
  3. package/dist/arrow/impl-arrowjs/iterate.d.ts +2 -0
  4. package/dist/arrow/impl-flechette/canonical.d.ts +1 -1
  5. package/dist/arrow/impl-flechette/index.d.ts +1 -1
  6. package/dist/arrow/impl-flechette/iterate.d.ts +2 -0
  7. package/dist/arrow/impl-flechette/schema.d.ts +19 -5
  8. package/dist/arrow/index.d.ts +1 -1
  9. package/dist/catalog/column-expressions.d.ts +8 -0
  10. package/dist/catalog/column-metadata.d.ts +11 -0
  11. package/dist/catalog/composite.d.ts +2 -1
  12. package/dist/catalog/descriptors.d.ts +21 -29
  13. package/dist/catalog/interface.d.ts +15 -20
  14. package/dist/catalog/macro-overloads.d.ts +4 -0
  15. package/dist/catalog/read-only.d.ts +1 -1
  16. package/dist/catalog/unconstrained-columns.d.ts +2 -0
  17. package/dist/client/client.d.ts +38 -14
  18. package/dist/client-entry.js +806 -115
  19. package/dist/client-entry.js.map +18 -14
  20. package/dist/functions/continuation.d.ts +69 -0
  21. package/dist/functions/projection.d.ts +18 -0
  22. package/dist/functions/table-in-out.d.ts +51 -7
  23. package/dist/functions/table.d.ts +6 -1
  24. package/dist/functions/types.d.ts +21 -0
  25. package/dist/generated/vgi-client.d.ts +178 -36
  26. package/dist/generated/vgi-protocol-schemas.d.ts +51 -1
  27. package/dist/generated/vgi-protocol-types.d.ts +317 -3
  28. package/dist/generated/vgi-service.d.ts +266 -29
  29. package/dist/index.core.d.ts +3 -1
  30. package/dist/index.js +1747 -320
  31. package/dist/index.js.map +45 -37
  32. package/dist/protocol/dispatch.d.ts +9 -9
  33. package/dist/protocol/handlers/aggregate.d.ts +1 -1
  34. package/dist/protocol/handlers/catalog/index.d.ts +1 -1
  35. package/dist/protocol/handlers/catalog/metadata.d.ts +1 -0
  36. package/dist/protocol/handlers/function.d.ts +1 -1
  37. package/dist/protocol/handlers/table-buffering.d.ts +1 -1
  38. package/dist/protocol/handlers/unimplemented.d.ts +1 -1
  39. package/dist/protocol/serializers/bind.d.ts +5 -1
  40. package/dist/protocol/types.d.ts +5 -0
  41. package/dist/rpc-server.d.ts +6 -6
  42. package/dist/serve-entry.js +1607 -436
  43. package/dist/serve-entry.js.map +33 -27
  44. package/dist/util/arrow/index.d.ts +1 -1
  45. package/dist/util/parent-rows.d.ts +8 -0
  46. package/dist/worker-cf-entry.d.ts +1 -1
  47. package/dist/worker-cf-entry.js +1901 -526
  48. package/dist/worker-cf-entry.js.map +45 -37
  49. package/dist/worker.d.ts +1 -1
  50. package/package.json +8 -7
  51. package/src/arrow/impl-arrowjs/index.ts +1 -1
  52. package/src/arrow/impl-arrowjs/iterate.ts +9 -1
  53. package/src/arrow/impl-arrowjs/project.ts +1 -1
  54. package/src/arrow/impl-flechette/canonical.ts +7 -5
  55. package/src/arrow/impl-flechette/index.ts +1 -1
  56. package/src/arrow/impl-flechette/ipc.ts +12 -0
  57. package/src/arrow/impl-flechette/iterate.ts +5 -0
  58. package/src/arrow/impl-flechette/project.ts +6 -8
  59. package/src/arrow/index.ts +1 -1
  60. package/src/catalog/column-expressions.ts +224 -0
  61. package/src/catalog/column-metadata.ts +151 -0
  62. package/src/catalog/composite.ts +5 -1
  63. package/src/catalog/contents-codec.ts +6 -1
  64. package/src/catalog/descriptors.ts +21 -29
  65. package/src/catalog/interface.ts +70 -55
  66. package/src/catalog/macro-overloads.ts +44 -0
  67. package/src/catalog/read-only.ts +69 -71
  68. package/src/catalog/unconstrained-columns.ts +23 -0
  69. package/src/client/client.ts +180 -69
  70. package/src/codec/asd.ts +3 -1
  71. package/src/filter-pushdown/collector.ts +17 -1
  72. package/src/functions/continuation.ts +202 -0
  73. package/src/functions/projection.ts +207 -0
  74. package/src/functions/table-in-out.ts +131 -56
  75. package/src/functions/table.ts +10 -0
  76. package/src/functions/types.ts +21 -0
  77. package/src/generated/vgi-client.ts +200 -37
  78. package/src/generated/vgi-protocol-schemas.ts +456 -41
  79. package/src/generated/vgi-protocol-types.ts +879 -5
  80. package/src/generated/vgi-service.ts +514 -42
  81. package/src/http/client-bundle.ts +1 -1
  82. package/src/http/fetch.ts +1 -1
  83. package/src/index.core.ts +10 -0
  84. package/src/protocol/dispatch.ts +9 -9
  85. package/src/protocol/handlers/aggregate.ts +1 -1
  86. package/src/protocol/handlers/catalog/admin.ts +10 -5
  87. package/src/protocol/handlers/catalog/index.ts +2 -2
  88. package/src/protocol/handlers/catalog/macro.ts +6 -5
  89. package/src/protocol/handlers/catalog/metadata.ts +16 -0
  90. package/src/protocol/handlers/catalog/table.ts +72 -26
  91. package/src/protocol/handlers/catalog/view.ts +24 -3
  92. package/src/protocol/handlers/function.ts +79 -1
  93. package/src/protocol/handlers/table-buffering.ts +1 -1
  94. package/src/protocol/handlers/unimplemented.ts +6 -6
  95. package/src/protocol/serializers/bind.ts +17 -1
  96. package/src/protocol/state-serializer.ts +7 -1
  97. package/src/protocol/types.ts +6 -0
  98. package/src/rpc-server.ts +9 -9
  99. package/src/util/arrow/index.ts +1 -1
  100. package/src/util/parent-rows.ts +41 -0
  101. package/src/worker-cf-entry.ts +3 -0
  102. package/src/worker.ts +1 -1
@@ -0,0 +1,202 @@
1
+ // Copyright 2025, 2026 Query Farm LLC - https://query.farm
2
+ // Continued output (table-in-out exchange).
3
+ //
4
+ // A table-in-out exchange answers each input batch with one reply. A function
5
+ // can answer one input with several: it emits each reply but the last with
6
+ // `moreOutputMetadata(true)`, which puts `vgi.status: HAVE_MORE_OUTPUT` on the
7
+ // reply. The client then asks for the next reply with a continuation tick -- a
8
+ // zero-row batch of the input schema carrying `vgi.status: CONTINUE` -- and the
9
+ // framework answers it by calling the function's `resume()`. Every reply's
10
+ // parent rows index the last real (non-tick) input batch.
11
+ //
12
+ // `resume()` gets no input, so the function's state must hold where to resume.
13
+ // Over HTTP that state reaches the next turn only inside the stream's state
14
+ // token, so keep it small: positions to resume from, never buffered output rows.
15
+ //
16
+ // The protocol is strict, with no capability negotiation: while output is
17
+ // pending a tick is the only valid input, and a tick is valid only then. Cache
18
+ // control may only ride an input's first reply, and "more" is refused outside a
19
+ // table-in-out exchange. Mirrors vgi-python's `emit(more=True)` / `resume()`.
20
+
21
+ import type { OutputCollector } from "@query-farm/vgi-rpc";
22
+ import type { VgiBatch } from "../arrow/index.js";
23
+
24
+ /** Metadata key carrying a table-in-out exchange status, on the batch itself. */
25
+ export const STATUS_KEY = "vgi.status";
26
+ /** Reply status: this input has more output; ask for it with a tick. */
27
+ export const HAVE_MORE_OUTPUT = "HAVE_MORE_OUTPUT";
28
+ /** Input status: a continuation tick, asking for the last input's next reply. */
29
+ export const CONTINUE = "CONTINUE";
30
+
31
+ const CACHE_KEY_PREFIX = "vgi.cache.";
32
+
33
+ /**
34
+ * Mark an emitted table-in-out reply as one of several for the same input
35
+ * batch when `more` is true: the client asks for the next one with a
36
+ * continuation tick, which the framework answers through the function's
37
+ * `resume()`. `false` adds nothing, so the last reply can pass its own
38
+ * condition. Composes with {@link parentRowsMetadata} and
39
+ * `cacheControlMetadata` via `extra`:
40
+ *
41
+ * ```ts
42
+ * out.emit(batch, moreOutputMetadata(state.row < state.counts.length,
43
+ * parentRowsMetadata(parents, batch.numRows)));
44
+ * ```
45
+ *
46
+ * Valid only from the `process()` or `resume()` of a table-in-out function
47
+ * that implements `resume()`; the framework reads it off the emitted reply.
48
+ */
49
+ export function moreOutputMetadata(more: boolean, extra?: Map<string, string>): Map<string, string> {
50
+ const md = new Map<string, string>(extra ?? []);
51
+ if (more) md.set(STATUS_KEY, HAVE_MORE_OUTPUT);
52
+ return md;
53
+ }
54
+
55
+ /** The metadata the turn's data batch went out with (per-emit over batch-carried). */
56
+ function replyMetadata(out: OutputCollector): Map<string, string> | null {
57
+ const idx = out.dataBatchIdx;
58
+ if (idx == null) return null;
59
+ const emitted = out.batches[idx];
60
+ const md = new Map<string, string>((emitted.batch as any).metadata ?? []);
61
+ for (const [k, v] of emitted.metadata ?? []) md.set(k, v);
62
+ return md;
63
+ }
64
+
65
+ /**
66
+ * Refuse "more" on a stream that cannot continue: anything but a table-in-out
67
+ * exchange, where the client would never send the tick. Run by the dispatcher
68
+ * after every non-table-in-out turn.
69
+ */
70
+ export function refuseMoreOutput(name: string, out: OutputCollector): void {
71
+ if (replyMetadata(out)?.get(STATUS_KEY) === HAVE_MORE_OUTPUT) {
72
+ throw new Error(
73
+ `${name}: HAVE_MORE_OUTPUT (moreOutputMetadata) is only valid in a table-in-out ` +
74
+ `function's process() or resume()`,
75
+ );
76
+ }
77
+ }
78
+
79
+ /** The exchange state a continuable table-in-out turn reads and updates. */
80
+ export interface ContinuationState {
81
+ /**
82
+ * Whether the last reply said HAVE_MORE_OUTPUT, so the next input must be a
83
+ * tick. Carried in the HTTP state token (see protocol/state-serializer.ts).
84
+ */
85
+ morePending?: boolean;
86
+ }
87
+
88
+ /**
89
+ * Run one table-in-out exchange turn under the continued-output rules.
90
+ *
91
+ * Classifies the input (a tick or real input), refuses the inputs the protocol
92
+ * forbids, calls `run(tick)` -- which calls `process()` for real input and
93
+ * `resume()` for a tick -- and records from the emitted reply whether output is
94
+ * now pending.
95
+ *
96
+ * `resumable` is whether the function implements `resume()`: one that does not
97
+ * may not say more.
98
+ */
99
+ export async function continuationTurn(
100
+ name: string,
101
+ eState: ContinuationState,
102
+ input: VgiBatch,
103
+ out: OutputCollector,
104
+ resumable: boolean,
105
+ run: (tick: boolean) => Promise<void>,
106
+ ): Promise<void> {
107
+ // The status rides the input batch's own metadata; vgi-rpc also surfaces it
108
+ // on the collector, so read either.
109
+ const inputStatus =
110
+ ((input as any)?.metadata as Map<string, string> | undefined)?.get(STATUS_KEY) ??
111
+ out.inputMetadata?.get(STATUS_KEY);
112
+ const tick = inputStatus === CONTINUE;
113
+ if (tick && !eState.morePending) {
114
+ throw new Error(`${name}: continuation tick received, but no output is pending`);
115
+ }
116
+ if (tick && input.numRows !== 0) {
117
+ throw new Error(`${name}: a continuation tick must have no rows, got ${input.numRows}`);
118
+ }
119
+ if (!tick && eState.morePending) {
120
+ throw new Error(`${name}: input received while output is pending; expected a continuation tick`);
121
+ }
122
+
123
+ await run(tick);
124
+
125
+ const md = replyMetadata(out);
126
+ // One reply per turn: a turn that emits none leaves the client waiting on
127
+ // the byte-stream transports (and, over HTTP, answers with a token-only body
128
+ // the client cannot tell from an empty result). An empty answer is a 0-row
129
+ // batch. Matches vgi-rpc-python's OutputCollector.validate(). (Several data
130
+ // batches are already refused by vgi-rpc's OutputCollector.emit.)
131
+ if (md == null) {
132
+ throw new Error(
133
+ tick
134
+ ? `${name}: resume() must emit a batch for every continuation tick`
135
+ : `${name}: process() must emit a batch for every input batch (No data batch was emitted)`,
136
+ );
137
+ }
138
+ const more = md.get(STATUS_KEY) === HAVE_MORE_OUTPUT;
139
+ if (more && !resumable) {
140
+ throw new Error(`${name}: emitted HAVE_MORE_OUTPUT but does not implement resume()`);
141
+ }
142
+ if (tick) {
143
+ // Every tick must be answered (above), and never with cache control.
144
+ for (const key of md.keys()) {
145
+ if (key.startsWith(CACHE_KEY_PREFIX)) {
146
+ throw new Error(
147
+ `${name}: cache control is only valid on an input's first reply, ` +
148
+ `not on one answering a continuation tick (${key})`,
149
+ );
150
+ }
151
+ }
152
+ }
153
+ eState.morePending = more;
154
+ }
155
+
156
+ /**
157
+ * Refuse, at definition, a continuable function the client cannot drive.
158
+ *
159
+ * `resume()` continues from the function's state alone, so it needs an
160
+ * `initialState` (the state is what the HTTP token carries between turns).
161
+ * `maxWorkers: 1` runs the function on one connection shared by every
162
+ * pipeline, which cannot leave output pending while another's input waits.
163
+ */
164
+ export function checkResumeContract(
165
+ name: string,
166
+ config: { resume?: unknown; initialState?: unknown; maxWorkers?: number },
167
+ ): void {
168
+ if (config.resume == null) return;
169
+ if (typeof config.resume !== "function") {
170
+ throw new Error(`${name}: resume must be a function`);
171
+ }
172
+ if (config.maxWorkers === 1) {
173
+ throw new Error(
174
+ `${name}: resume() (continued output) is not supported with maxWorkers: 1; ` +
175
+ `the client runs such a function on one shared connection.`,
176
+ );
177
+ }
178
+ if (config.initialState == null) {
179
+ throw new Error(
180
+ `${name}: resume() continues from its state alone, so the function must ` +
181
+ `declare an initialState holding where to resume.`,
182
+ );
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Check `inputRowsPerCall`: a positive integer, on a blended row-transform
188
+ * function only (the extension refuses it at bind too).
189
+ */
190
+ export function checkInputRowsPerCall(name: string, value: unknown, blended: boolean): number | undefined {
191
+ if (value == null) return undefined;
192
+ if (!blended) {
193
+ throw new Error(
194
+ `${name}: inputRowsPerCall applies only to a blended row-transform function, ` +
195
+ `whose per-row input the client can split into calls`,
196
+ );
197
+ }
198
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1) {
199
+ throw new Error(`${name}: inputRowsPerCall must be a positive integer, got ${String(value)}`);
200
+ }
201
+ return value;
202
+ }
@@ -0,0 +1,207 @@
1
+ // Copyright 2025, 2026 Query Farm LLC - https://query.farm
2
+ import {
3
+ schema,
4
+ serializeSchema,
5
+ deserializeBatch,
6
+ type VgiSchema,
7
+ } from "../arrow/index.js";
8
+ import { validateEncoded } from "../catalog/column-expressions.js";
9
+ import { decodeSqlExpression } from "../generated/vgi-protocol-types.js";
10
+ import { batchToScalarDict } from "../util/arrow/index.js";
11
+ import type { BindRequest, BindResponse } from "../protocol/types.js";
12
+ import {
13
+ normalizeBindRepeatability,
14
+ parseBindRepeatability,
15
+ } from "../protocol/serializers/bind.js";
16
+ export const SCALAR_PROJECTION_PROFILE = "vgi.expression.duckdb.scalar.v1";
17
+ export interface ProjectionProposal {
18
+ bindCall: BindRequest;
19
+ bindResult: BindResponse;
20
+ expressions: Uint8Array[];
21
+ resultSchema: VgiSchema;
22
+ }
23
+ export interface ProjectionAcceptance {
24
+ acceptedIndices: number[];
25
+ bindResult: BindResponse | null;
26
+ }
27
+ /** Strict envelope boundary for the projection RPC and its original bind records. */
28
+ export function projectionRecord(
29
+ bytes: Uint8Array,
30
+ expected: VgiSchema,
31
+ ): Record<string, any> {
32
+ if (!bytes.length || bytes.length > 8 * 1024 * 1024)
33
+ throw new Error("invalid projection record size");
34
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
35
+ let offset = 0,
36
+ schemas = 0,
37
+ batches = 0;
38
+ while (offset < bytes.length) {
39
+ if (bytes.length - offset < 4)
40
+ throw new Error("truncated projection IPC prefix");
41
+ const prefix = view.getInt32(offset, true) === -1 ? 8 : 4;
42
+ if (bytes.length - offset < prefix)
43
+ throw new Error("truncated projection IPC prefix");
44
+ const length = view.getInt32(offset + prefix - 4, true);
45
+ offset += prefix;
46
+ if (length === 0) {
47
+ break;
48
+ }
49
+ if (length < 0 || offset + length > bytes.length)
50
+ throw new Error("invalid projection IPC message");
51
+ const table = offset + view.getUint32(offset, true);
52
+ const vtable = table - view.getInt32(table, true);
53
+ const slot = (id: number) =>
54
+ 4 + id * 2 < view.getUint16(vtable, true)
55
+ ? view.getUint16(vtable + 4 + id * 2, true)
56
+ : 0;
57
+ const kindSlot = slot(1),
58
+ bodySlot = slot(3);
59
+ const kind = kindSlot ? view.getUint8(table + kindSlot) : 0;
60
+ const body = bodySlot
61
+ ? Number(view.getBigInt64(table + bodySlot, true))
62
+ : 0;
63
+ if (
64
+ body < 0 ||
65
+ body > bytes.length - offset - length ||
66
+ !Number.isSafeInteger(body)
67
+ )
68
+ throw new Error("invalid projection IPC body");
69
+ if (kind === 1 && schemas === 0 && batches === 0) schemas++;
70
+ else if (kind === 2 && schemas === 1 && batches === 0) {
71
+ /* dictionary before record */
72
+ } else if (kind === 3 && schemas === 1 && batches === 0) batches++;
73
+ else throw new Error("projection requires one complete IPC batch");
74
+ offset += length + body;
75
+ }
76
+ // Arrow permits physical EOF after a complete message, with or without EOS.
77
+ if (offset !== bytes.length || schemas !== 1 || batches !== 1)
78
+ throw new Error("projection requires one complete IPC batch");
79
+ const batch = deserializeBatch(bytes);
80
+ // IPC dictionary ids are stream-local and may be reassigned on re-encoding.
81
+ // Compare the exact Arrow shape and metadata instead of those transport ids.
82
+ const metadata = (m: ReadonlyMap<string, string>) =>
83
+ [...m].sort(([a], [b]) => a.localeCompare(b));
84
+ const fieldShape = (f: any): unknown => [
85
+ f.name,
86
+ f.nullable,
87
+ String(f.type),
88
+ metadata(f.metadata),
89
+ (f.type.children ?? []).map(fieldShape),
90
+ ];
91
+ const shape = (s: VgiSchema) =>
92
+ JSON.stringify([s.fields.map(fieldShape), metadata(s.metadata)]);
93
+ if (batch.numRows !== 1 || shape(batch.schema) !== shape(expected))
94
+ throw new Error("invalid projection record schema/row count");
95
+ for (let i = 0; i < expected.fields.length; i++)
96
+ if (!expected.fields[i]!.nullable && batch.getChildAt(i)?.get(0) == null)
97
+ throw new Error("required projection field is NULL");
98
+ return batchToScalarDict(batch);
99
+ }
100
+ export function validateProjectionOffer(result: BindResponse): void {
101
+ const profiles = result.projection_expression_profiles ?? [];
102
+ if (
103
+ profiles.length > 64 ||
104
+ new Set(profiles).size !== profiles.length ||
105
+ profiles.some(
106
+ (p) =>
107
+ typeof p !== "string" ||
108
+ p.length > 256 ||
109
+ !/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*\.v[1-9][0-9]*$/.test(p),
110
+ )
111
+ )
112
+ throw new Error("unsupported projection profile offer");
113
+ }
114
+ export function validateProjectionProposal(p: ProjectionProposal): void {
115
+ parseBindRepeatability(p.bindResult.repeatability);
116
+ validateProjectionOffer(p.bindResult);
117
+ if (
118
+ p.bindCall.function_type !== "table" ||
119
+ p.bindCall.input_schema !== null ||
120
+ p.bindCall.schema_path == null
121
+ )
122
+ throw new Error("projection requires an ordinary table and explicit owner");
123
+ if (
124
+ [
125
+ p.bindResult.lookup_secret_types,
126
+ p.bindResult.lookup_scopes,
127
+ p.bindResult.lookup_names,
128
+ ].some((v) => v?.length)
129
+ )
130
+ throw new Error("projection cannot request secrets");
131
+ if (
132
+ p.expressions.length < 1 ||
133
+ p.expressions.length > 1024 ||
134
+ p.resultSchema.fields.length !== p.expressions.length ||
135
+ p.resultSchema.metadata.size
136
+ )
137
+ throw new Error("invalid projection result schema/count");
138
+ const names = [
139
+ ...p.bindResult.output_schema.fields,
140
+ ...p.resultSchema.fields,
141
+ ].map((f) => f.name.replace(/[A-Z]/g, (c) => c.toLowerCase()));
142
+ if (
143
+ names.some((n) => !n || n.includes("\0")) ||
144
+ new Set(names).size !== names.length
145
+ )
146
+ throw new Error("ambiguous projection column names");
147
+ let context: string | undefined;
148
+ for (const raw of p.expressions) {
149
+ validateEncoded(
150
+ btoa(Array.from(raw, (b) => String.fromCharCode(b)).join("")),
151
+ p.bindCall.schema_path,
152
+ );
153
+ const expression = decodeSqlExpression(raw);
154
+ if (
155
+ !(p.bindResult.projection_expression_profiles ?? []).includes(
156
+ expression.profile,
157
+ )
158
+ )
159
+ throw new Error("projection profile was not offered");
160
+ const next = JSON.stringify(expression.evaluation_context);
161
+ if (context !== undefined && next !== context)
162
+ throw new Error("projection contexts differ");
163
+ context = next;
164
+ }
165
+ }
166
+ export function validateProjectionAcceptance(
167
+ p: ProjectionProposal,
168
+ r: ProjectionAcceptance,
169
+ ): void {
170
+ validateProjectionProposal(p);
171
+ if ((r.acceptedIndices.length === 0) !== (r.bindResult === null))
172
+ throw new Error("projection indices and bind result must occur together");
173
+ let previous = -1;
174
+ for (const i of r.acceptedIndices) {
175
+ if (!Number.isSafeInteger(i) || i <= previous || i >= p.expressions.length)
176
+ throw new Error("invalid accepted projection index");
177
+ previous = i;
178
+ }
179
+ if (!r.bindResult) return;
180
+ validateProjectionOffer(r.bindResult);
181
+ if (
182
+ normalizeBindRepeatability(r.bindResult.repeatability) !==
183
+ p.bindResult.repeatability
184
+ )
185
+ throw new Error("accepted projection changed bind repeatability");
186
+ if (
187
+ JSON.stringify(r.bindResult.projection_expression_profiles ?? []) !==
188
+ JSON.stringify(p.bindResult.projection_expression_profiles ?? []) ||
189
+ [
190
+ r.bindResult.lookup_secret_types,
191
+ r.bindResult.lookup_scopes,
192
+ r.bindResult.lookup_names,
193
+ ].some((v) => v?.length)
194
+ )
195
+ throw new Error("accepted projection changed bind offer/secrets");
196
+ const expected = schema(
197
+ [
198
+ ...p.bindResult.output_schema.fields,
199
+ ...r.acceptedIndices.map((i) => p.resultSchema.fields[i]),
200
+ ],
201
+ p.bindResult.output_schema.metadata,
202
+ );
203
+ const a = serializeSchema(expected),
204
+ b = serializeSchema(r.bindResult.output_schema);
205
+ if (a.length !== b.length || a.some((v, i) => v !== b[i]))
206
+ throw new Error("accepted projection changed append-only schema");
207
+ }