dirsql 0.4.61 → 0.4.62

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.
@@ -111,6 +111,7 @@ its `embed()` function exactly this way.
111
111
  | `command` | yes (non-empty) | The worker command. Argv-split with the same no-shell quoting rules as [command hooks](./hooks.md#argv-not-a-shell); runs in the config file's directory. |
112
112
  | `deterministic` | no (default `false`) | When `true`, the function is registered with `SQLITE_DETERMINISTIC`, letting SQLite cache and reuse results for identical arguments within a query. Only set it when the worker really is a pure function of its arguments. |
113
113
  | `timeout` | no | Per-**call** time bound: a positive integer is whole seconds (`timeout = 600`), a string is an integer suffixed `s` or `ms` (`"600s"`, `"250ms"`). When absent, the function mechanism's own 30-second default applies. |
114
+ | `batch` | no | A positive integer: the most calls one **batched request** carries. When set, a statement's values are gathered and sent to the worker in bulk (see [Batching](#batching)); the worker must then speak the batched protocol shape as well as the single-call one. When absent, the worker only ever sees single calls. |
114
115
 
115
116
  ```toml
116
117
  [[dirsql.function]]
@@ -173,6 +174,42 @@ request line in, one response line out, per call:
173
174
  - **stderr passes through** to `dirsql`'s stderr, so a worker's progress
174
175
  bars and download logs reach the terminal.
175
176
 
177
+ ### Batching
178
+
179
+ One round trip per row is the wrong shape for a worker whose cost is
180
+ per-request rather than per-value — an embedding model encodes a list of
181
+ texts in little more time than one. A function declaring `batch = N` is sent
182
+ values in bulk instead:
183
+
184
+ - **Request:** `{"calls": [[<arg>, ...], ...]}` — up to `N` calls, each
185
+ encoded exactly as a single call's argument list.
186
+ - **Response:** `{"results": [<response>, ...]}` — one single-call response
187
+ (`{"ok": ...}` with its optional `"meta"`, or `{"err": ...}`) per call, in
188
+ order. A per-call `{"err": ...}` fails the query the way it would on a
189
+ single call. A top-level `{"err": "message"}` instead fails every call in
190
+ the request.
191
+ - The round trip is bounded by the per-call `timeout` **times the number of
192
+ calls** in the request.
193
+
194
+ A batching worker must still answer `{"call": [...]}`: `dirsql` gathers a
195
+ statement's values by running it twice. The first run makes one ordinary
196
+ round trip for the function's first value, binds that reply in place of every
197
+ later distinct argument tuple, and queues those tuples into batched requests
198
+ of at most `N`; the second run is served from the replies. A statement that
199
+ never calls a batched function runs once, exactly as before. Values are
200
+ deduplicated along the way, so the [progress line](./cli.md#progress-reporting)
201
+ counts distinct calls, whichever request shape carried them.
202
+
203
+ ```toml
204
+ [[dirsql.function]]
205
+ name = "embed"
206
+ args = [1, 2]
207
+ command = "dirsql-plugin-embeddings worker"
208
+ deterministic = true
209
+ timeout = "600s"
210
+ batch = 256
211
+ ```
212
+
176
213
  ## `[[table]]`
177
214
 
178
215
  Each entry maps a glob pattern to a SQL table. A table's columns are exactly
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.61",
3
+ "version": "0.4.62",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -221,10 +221,10 @@
221
221
  ]
222
222
  },
223
223
  "optionalDependencies": {
224
- "@dirsql/lib-linux-x64-gnu": "0.4.61",
225
- "@dirsql/lib-linux-arm64-gnu": "0.4.61",
226
- "@dirsql/lib-darwin-x64": "0.4.61",
227
- "@dirsql/lib-darwin-arm64": "0.4.61",
228
- "@dirsql/lib-win32-x64-msvc": "0.4.61"
224
+ "@dirsql/lib-linux-x64-gnu": "0.4.62",
225
+ "@dirsql/lib-linux-arm64-gnu": "0.4.62",
226
+ "@dirsql/lib-darwin-x64": "0.4.62",
227
+ "@dirsql/lib-darwin-arm64": "0.4.62",
228
+ "@dirsql/lib-win32-x64-msvc": "0.4.62"
229
229
  }
230
230
  }