@query-farm/vgi 0.21.0 → 0.23.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.
@@ -36,6 +36,7 @@ export declare const CACHE_STALE_WHILE_REVALIDATE_KEY = "vgi.cache.stale_while_r
36
36
  export declare const CACHE_STALE_IF_ERROR_KEY = "vgi.cache.stale_if_error";
37
37
  export declare const CACHE_NOT_MODIFIED_KEY = "vgi.cache.not_modified";
38
38
  export declare const CACHE_PARTITION_SCOPE_KEY = "vgi.cache.partition_scope";
39
+ export declare const CACHE_PER_VALUE_KEY = "vgi.cache.per_value";
39
40
  export declare const CACHE_IF_NONE_MATCH_KEY = "vgi.cache.if_none_match";
40
41
  export declare const CACHE_IF_MODIFIED_SINCE_KEY = "vgi.cache.if_modified_since";
41
42
  export declare const CACHE_SCOPE_CATALOG = "catalog";
@@ -82,6 +83,31 @@ export interface CacheControl {
82
83
  * partitions without calling the worker. Only meaningful for a
83
84
  * `SINGLE_VALUE_PARTITIONS` table function; purely additive. */
84
85
  partitionScope?: boolean;
86
+ /**
87
+ * Opt in to per-VALUE memoization: in addition to the whole-result entry, the
88
+ * client memoizes each distinct worker-input tuple's output keyed on that
89
+ * tuple, so the same value is served without calling the worker on a later
90
+ * chunk or a later query. Only meaningful for an exchange-mode MAP — a
91
+ * scalar, or a blended table-in-out invoked through a correlated `LATERAL`.
92
+ *
93
+ * **Default off, and it should stay off unless one call is genuinely
94
+ * expensive.** This is not a free win: serving a value from the memo costs a
95
+ * key probe, a decode and a per-value assembly step, and that only pays back
96
+ * when it is cheaper than asking you for the answer. For a cheap map —
97
+ * arithmetic, a string tweak, a lookup in a table the worker already has in
98
+ * memory — it is a large net loss (the engine measures a per-value serve at
99
+ * roughly 50x the cost of just calling the worker for a simple arithmetic
100
+ * map). Only the function author knows which side of that line a call falls
101
+ * on, which is why the engine will not guess: turn it on for model
102
+ * inference, geocoding, an external API call, or anything rate-limited or
103
+ * billed per request.
104
+ *
105
+ * Independent of freshness: `ttl`/`expires` make a result cacheable at all,
106
+ * while this decides whether the per-value tier is additionally populated.
107
+ * Requires a deterministic, side-effect-free function, exactly like the rest
108
+ * of the result cache.
109
+ */
110
+ perValue?: boolean;
85
111
  }
86
112
  /**
87
113
  * Render a {@link CacheControl} to the `vgi.cache.*` batch-metadata map.
@@ -4,6 +4,8 @@ export declare class CompositeCatalogInterface extends CatalogInterface {
4
4
  private readonly _backends;
5
5
  constructor(_backends: CatalogInterface[]);
6
6
  private _route;
7
+ /** Route to the owning backend and ask it, so the answer is per-attachment. */
8
+ catalogNameForAttach(attachOpaqueData: Uint8Array): string | null;
7
9
  catalogs(): string[];
8
10
  catalogsInfo(): Promise<CatalogInfo[]>;
9
11
  attach(name: string, options?: Record<string, unknown>, dataVersionSpec?: string | null, implementationVersion?: string | null): Promise<CatalogAttachResult>;
@@ -180,6 +180,17 @@ export declare function buildScanBranchesResult(branches: ScanBranchInput[], req
180
180
  */
181
181
  type Awaitable<T> = T | Promise<T>;
182
182
  export declare abstract class CatalogInterface {
183
+ /**
184
+ * Which catalog an `attach_opaque_data` belongs to, or null if unknown.
185
+ *
186
+ * Two catalogs served by one worker may declare the same schema *and*
187
+ * function name, in which case the attachment is the only thing that tells
188
+ * them apart — the bind path uses this to scope function resolution. The
189
+ * default answers from `catalogs()` when this interface owns exactly one,
190
+ * which is right for every single-catalog implementation; the composite
191
+ * overrides it to route by its backend index byte.
192
+ */
193
+ catalogNameForAttach(_attachOpaqueData: Uint8Array): string | null;
183
194
  abstract catalogs(): string[];
184
195
  /**
185
196
  * Attach this catalog. The framework already validates ATTACH options
@@ -2004,7 +2004,8 @@ var BIND_REQUEST_SCHEMA = schema2([
2004
2004
  field2("transaction_opaque_data", binary2(), true),
2005
2005
  field2("resolved_secrets_provided", bool2(), false),
2006
2006
  field2("at_unit", utf82(), true),
2007
- field2("at_value", utf82(), true)
2007
+ field2("at_value", utf82(), true),
2008
+ field2("schema_name", utf82(), true)
2008
2009
  ]);
2009
2010
  var COPY_FROM_STRUCT_TYPE = struct2([
2010
2011
  field2("format", utf82(), false),
@@ -2036,7 +2037,8 @@ function serializeBindRequest(req) {
2036
2037
  transaction_opaque_data: req.transaction_opaque_data ?? null,
2037
2038
  resolved_secrets_provided: req.resolved_secrets_provided ?? false,
2038
2039
  at_unit: req.at_unit ?? null,
2039
- at_value: req.at_value ?? null
2040
+ at_value: req.at_value ?? null,
2041
+ schema_name: req.schema_name ?? null
2040
2042
  };
2041
2043
  const extraFields = [];
2042
2044
  if (req.copy_from) {
@@ -3921,4 +3923,4 @@ export {
3921
3923
  ArgumentValidationError
3922
3924
  };
3923
3925
 
3924
- //# debugId=D04A9CC224B063B264756E2164756E21
3926
+ //# debugId=FCC2DEE998E0D9AC64756E2164756E21