@voltro/database 0.48.0 → 0.49.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 +67 -0
- package/dist/index.d.ts +64 -34
- package/dist/index.js +674 -669
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -39,6 +39,73 @@ _Changes staged for the next release accumulate here (rolled up from
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
+
## [0.49.0] — 2026-08-23
|
|
43
|
+
|
|
44
|
+
### ⚠ BREAKING
|
|
45
|
+
|
|
46
|
+
- **@voltro/cli, @voltro/data-transfer, @voltro/database, @voltro/sql-sqlite, @voltro/voltro** — A data transfer is a series of short requests now — no single one may outlive a caller's budget.
|
|
47
|
+
|
|
48
|
+
**The rule:** *a request that carries bytes never runs a transfer; a request that starts a transfer never carries bytes.* It was broken in the worst available place. The upload was already chunked and resumable — many short requests, each abandonable — and then the FINAL chunk fell through and ran the whole import. So the longest request of the flow arrived AFTER the entire upload had succeeded, and a caller under a policy that caps a single request (a job runner that kills a client at ten minutes; a 30 s ingress ceiling) lost the most expensive thing they had already paid for. A single-request upload had the same shape without the excuse, and the export had no protocol at all: one request that read the whole database and streamed it back.
|
|
49
|
+
|
|
50
|
+
**Import.** `POST /_voltro/admin/import` accumulates and answers `202`. `POST /_voltro/admin/import/start` begins the run and answers `202 { runId }` as soon as the run's first row exists. `start` is idempotent per upload — it is a short request and therefore a retryable one, and without a claim a retry would begin a second destructive run from the same bytes. A claim whose run has ENDED is taken over rather than honoured forever, so a process that dies holding one cannot poison a bundle.
|
|
51
|
+
|
|
52
|
+
**Export.** `POST /_voltro/admin/export` answers `202 { runId }` and produces in the background; the bytes come back from `GET /_voltro/admin/export/download?runId=&offset=&length=` in ranges, resumable, with the total in a header. Object storage (`--bundle-key`) remains for a bundle you want to KEEP — it is no longer the only way to get one out, because requiring it would leave an instance without storage unable to export at all.
|
|
53
|
+
|
|
54
|
+
**The client.** `--max-request-seconds` (or `VOLTRO_MAX_REQUEST_SECONDS`) declares the budget — declared rather than probed, because the thing that kills a request is a policy on the caller's side and only they know it. `--detach` returns once the run has started and says the outcome is NOT known. Attached, the CLI polls the record and prints per-table progress; Ctrl-C then loses the watching and never the run.
|
|
55
|
+
|
|
56
|
+
**The trap, stated because it is the one way to get this wrong:** a failure used to arrive in the response (409 on drift, 409 on a refused mode, 500 otherwise). After the split the response is a `202`, so **a client deriving its exit code from the status line reports a failed import as a success.** The exit code comes from the polled record, in one shared function, and the drift check moved into `start` where it can still be a refusal that leaves no history.
|
|
57
|
+
|
|
58
|
+
**Two knobs that were constants.** `VOLTRO_IMPORT_UPLOAD_DIR` and `VOLTRO_EXPORT_ARTIFACT_DIR` move the staging areas off the default temp filesystem — which on a container is frequently a small tmpfs, so an instance simply could not accept a bundle the size a grown database produces, and the failure arrived as a write error halfway through an upload somebody had been waiting on.
|
|
59
|
+
|
|
60
|
+
**Renamed:** `voltro data imports` → `voltro data transfers`, and `_voltro_data_imports` → `_voltro_data_transfers` with a `direction` column. The command showed one direction and now shows both; the table rename carries its rows via the declarative differ on every dialect and needs nothing from you. The CLI rename ships a `manual` codemod — the command lives in scripts, CI jobs and runbooks, which `voltro update` cannot see or rewrite. The four PUBLIC exports that named the same record were renamed with it (`ImportRun`, `describeImportRun`, `IMPORT_RUNS_TABLE`, `_voltroImportRunsTable`); those are application source, they ship their own `transform` codemod, and they have their own entry.
|
|
61
|
+
- **@voltro/database, @voltro/voltro** — The run-history exports say `transfer`, not `import`.
|
|
62
|
+
|
|
63
|
+
`@voltro/database` (and `voltro/database`) renamed four public exports along with the table behind them:
|
|
64
|
+
|
|
65
|
+
| was | is | |---|---| | `ImportRun` | `DataTransferRun` | | `describeImportRun` | `describeTransferRun` | | `IMPORT_RUNS_TABLE` | `DATA_TRANSFERS_TABLE` | | `_voltroImportRunsTable` | `_voltroDataTransfersTable` |
|
|
66
|
+
|
|
67
|
+
An EXPORT writes to this record now — the row carries a `direction` — so every one of those names described half of what it holds.
|
|
68
|
+
|
|
69
|
+
A `transform` codemod rewrites all four, alias-aware, from either module spelling. It also rewrites a hand-spelled `_voltro_data_imports` in a string, template or raw-SQL fragment, and that is the half worth stating: the four identifiers announce themselves as compile errors, while a query that addresses the table by name has nothing to fail on. The table itself moves with its rows via the declarative differ on every dialect.
|
|
70
|
+
|
|
71
|
+
This is filed apart from the transfer-protocol entry beside it deliberately. That one's codemod is `manual` and is about a CLI invocation living in scripts and CI jobs; this one is application source and is rewritten for you. Reading the first as covering both is what would leave a build broken with a note saying nothing in your source was affected.
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
|
|
75
|
+
- **@voltro/database, @voltro/data-transfer, @voltro/cli** — An import records WHETHER it staged, and a soft-dropped column says so in a drift refusal.
|
|
76
|
+
|
|
77
|
+
**`_voltro_data_imports.staged`.** The pre-upload preflight says what the instance WILL do; the run's own line says what it did — and that line is printed inside the instance, which is exactly where an operator using `--target api` cannot read it. So "we were told it would stage" and "it staged" were two claims with no way to close the gap between them from outside. The column is `null` for a mode where the question does not arise; `voltro data imports` and `GET /_voltro/admin/imports` both carry it.
|
|
78
|
+
|
|
79
|
+
**A soft-dropped column is named as one.** `<original>__dropped_<stamp>` is what the differ leaves behind when an app stops declaring a column — only the database that did the drop has it, so it drifts against every target. The refusal reported it as an ordinary missing column ("the value has nowhere to go"), which points at the TARGET's schema: the one place the fix does not lie. It now says where the column lives and how to reclaim it.
|
|
80
|
+
|
|
81
|
+
### Fixed
|
|
82
|
+
|
|
83
|
+
- **@voltro/data-transfer, @voltro/sql-sqlite, @voltro/database** — A successful `--mode replace --no-atomic` left a marker that refused the next boot.
|
|
84
|
+
|
|
85
|
+
Two defects, one visible symptom, and both were silent by construction.
|
|
86
|
+
|
|
87
|
+
**The clear was gated on the WRITE's condition.** `!(useLedger && ledger.truncated)` means "an earlier attempt already recorded this destructive run, do not write a second row" — correct on the write. Copied down to the clear its meaning inverts: `ledger.truncated` is set by the emptying step of THIS run, so on `--no-atomic` (the only mode where `useLedger` is true) the clear was skipped by the very run that wrote the marker.
|
|
88
|
+
|
|
89
|
+
**And a `Date` in a predicate is not bindable on sqlite.** `better-sqlite3` binds numbers, strings, bigints, buffers and null; the row path has coerced Dates since that store was written, and the eager-join compiler carried its own private copy of the fix, but `query` / `updateMany` / `deleteMany` bound the raw value. So every comparison of a timestamp column against a `Date` failed with `Failed to execute statement` — including the marker's clear, which swallows its errors ON PURPOSE (a store with no marker table must not fail an import over a bookkeeping row) and therefore said nothing. The retention sweep compares `lt(column, cutoff)` the same way.
|
|
90
|
+
|
|
91
|
+
Together: a fully successful replace left the marker standing, and the next boot REFUSED with "a destructive import did not finish" over a database that was completely fine. The one recovery is a command the operator has no reason to think they need. It stayed invisible because `atomic` defaults to true for `replace`, and because a staged replace writes no marker at all — two defaults hiding the one mode that exists for large, interruptible loads.
|
|
92
|
+
|
|
93
|
+
The coercion is shared now and applied at all three predicate sites, with a guard that fails on a fourth that forgets. A dry run also closes its trace row: a preview that finished instantly used to leave the record open, so a polling caller waited out its whole budget over a run that was long done.
|
|
94
|
+
- **@voltro/cli** — `voltro codegen` declared twenty framework tables fewer than a boot.
|
|
95
|
+
|
|
96
|
+
The app half of this was fixed last release and looked like the whole thing. It was not: `codegen` derived the FEATURE MIX from the file list it had just walked, and that list is the entity/relations set — which contains no `*.workflow.tsx`, no `*.agent.ts`, no `*.cron.tsx`. So every feature flag came back false, and the dialect was never passed at all, taking `_voltro_cdc_offsets` with it. Measured on an app with two workflow files: 18 framework tables where the shared assembly produces 33.
|
|
97
|
+
|
|
98
|
+
It calls `assembleFrameworkTables({ root })` now — the same entry `voltro db plan/apply` uses, which detects the mix from the root rather than being handed one.
|
|
99
|
+
|
|
100
|
+
The parity guard moved with it. Comparing the two WALKS could not see this: both walks were right about files, and the divergence was introduced one layer past them. It compares the assembled SETS now, and runs codegen's own table function on a tree whose only feature signals are a workflow file and an agent file — a source assertion that the right function is CALLED cannot see a wrong argument handed to it, and a wrong argument is what this was.
|
|
101
|
+
- **@voltro/cli** — `voltro data --help` advertised four subcommands out of nine.
|
|
102
|
+
|
|
103
|
+
It printed `<export|import|backup|restore>` while the command dispatched those four plus `imports`, `inspect`, `unpack`, `clear-replace-marker` and `clear-staging`. A quoted enumeration is read as exhaustive — the same failure `subcommandNames.ts` was written for after a `db` list cost two wrong conclusions — and the missing entry here is the one that answers "what is my import doing right now" for somebody who cannot reach the pod.
|
|
104
|
+
|
|
105
|
+
`subcommandHelpParity.test.ts` had listed `data` among the commands it could not check, loudly and correctly: there was no name list to check against. There is one now (`DATA_SUBCOMMANDS`), the dispatch is a keyed `Record`, so a subcommand with no name and a name with no handler are both compile errors, and the usage line is generated from the same array. `data` is out of the unchecked list.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
42
109
|
## [0.48.0] — 2026-08-22
|
|
43
110
|
|
|
44
111
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -824,6 +824,30 @@ export declare const clearTableRegistry: () => void;
|
|
|
824
824
|
/** Test seam / dev-restart seam. */
|
|
825
825
|
export declare const clearWriteRecorders: () => void;
|
|
826
826
|
|
|
827
|
+
/**
|
|
828
|
+
* A predicate whose VALUES are bindable by the sqlite driver.
|
|
829
|
+
*
|
|
830
|
+
* Exported because it was module-private here, applied on the eager-join path
|
|
831
|
+
* only — and the plain `query` / `updateMany` / `deleteMany` paths bound the raw
|
|
832
|
+
* value. `better-sqlite3` refuses anything that is not a number, string, bigint,
|
|
833
|
+
* buffer or null, so every predicate comparing a timestamp column against a
|
|
834
|
+
* `Date` FAILED with `Failed to execute statement`, on the one dialect where the
|
|
835
|
+
* row path had a coercion sitting three files away.
|
|
836
|
+
*
|
|
837
|
+
* Found through the interrupted-replace marker: the clear swallows its errors by
|
|
838
|
+
* design (a missing marker table must not fail an import), so a successful
|
|
839
|
+
* `replace` left the marker standing and the NEXT BOOT REFUSED over a database
|
|
840
|
+
* that was fine. The retention sweep compares `lt(column, cutoff)` the same way.
|
|
841
|
+
*
|
|
842
|
+
* NOT a duplicate of `predicateCoercion.ts`, and worth keeping straight before
|
|
843
|
+
* anyone merges them: that one runs the other direction — it accepts a loose
|
|
844
|
+
* wire value (an epoch number, an ISO string) and normalises it INTO a `Date`
|
|
845
|
+
* for a temporal column. This one takes whatever the predicate ended up holding
|
|
846
|
+
* and makes it bindable by ONE driver. Both can apply to the same value, in that
|
|
847
|
+
* order.
|
|
848
|
+
*/
|
|
849
|
+
export declare const coercePredicateForSqlite: (predicate: Predicate) => Predicate;
|
|
850
|
+
|
|
827
851
|
/**
|
|
828
852
|
* The value to bind for `column`, given what the table declares it as.
|
|
829
853
|
* Returns `value` unchanged whenever nothing unambiguous applies — including
|
|
@@ -834,6 +858,9 @@ export declare const coercePredicateValue: (columnType: ColumnType | undefined,
|
|
|
834
858
|
/** Same, for the array-valued operators (`inSet` / `notInSet`). */
|
|
835
859
|
export declare const coercePredicateValues: (columnType: ColumnType | undefined, values: ReadonlyArray<unknown>) => ReadonlyArray<unknown>;
|
|
836
860
|
|
|
861
|
+
/** The value half of {@link coercePredicateForSqlite}. */
|
|
862
|
+
export declare const coerceValueForSqlite: (value: unknown) => unknown;
|
|
863
|
+
|
|
837
864
|
/**
|
|
838
865
|
* Walk a predicate tree + yield every sub-query descriptor. The
|
|
839
866
|
* store calls this before evaluating to know which sub-queries to
|
|
@@ -2006,6 +2033,8 @@ export declare const crdtText: () => ColumnBuilder<Uint8Array | null, "bytes">;
|
|
|
2006
2033
|
/** The attribution on the current async stack, or `undefined` outside a request. */
|
|
2007
2034
|
export declare const currentWriteAttribution: () => WriteAttribution | undefined;
|
|
2008
2035
|
|
|
2036
|
+
export declare const DATA_TRANSFERS_TABLE = "_voltro_data_transfers";
|
|
2037
|
+
|
|
2009
2038
|
/**
|
|
2010
2039
|
* The application's `database` handle. Indexed by table name; each entry is
|
|
2011
2040
|
* a `Query` over the table's row type AND a `using()` constraint over the
|
|
@@ -2423,6 +2452,23 @@ export declare interface DataStore {
|
|
|
2423
2452
|
refreshChangeCaptureExclusions?(): Promise<ChangeCaptureExclusionRefresh>;
|
|
2424
2453
|
}
|
|
2425
2454
|
|
|
2455
|
+
/** One transfer, as the inspector reads it back. */
|
|
2456
|
+
export declare interface DataTransferRun {
|
|
2457
|
+
readonly id: string;
|
|
2458
|
+
readonly direction: 'import' | 'export' | string;
|
|
2459
|
+
readonly startedAt: Date;
|
|
2460
|
+
readonly finishedAt: Date | null;
|
|
2461
|
+
readonly mode: string;
|
|
2462
|
+
readonly via: string;
|
|
2463
|
+
readonly bundle: string | null;
|
|
2464
|
+
readonly sourceFingerprint: string | null;
|
|
2465
|
+
readonly tablesWritten: number;
|
|
2466
|
+
readonly rowsWritten: number;
|
|
2467
|
+
readonly failure: string | null;
|
|
2468
|
+
/** Whether the run staged. `null` when the mode makes the question moot. */
|
|
2469
|
+
readonly staged: boolean | null;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2426
2472
|
/** Calendar date without time. */
|
|
2427
2473
|
export declare const date: () => ColumnBuilder<Date, "date", boolean>;
|
|
2428
2474
|
|
|
@@ -2750,14 +2796,6 @@ export declare const deriveTypeIdPrefix: (tableName: string) => string;
|
|
|
2750
2796
|
*/
|
|
2751
2797
|
export declare const describeDriverError: (err: unknown) => string | undefined;
|
|
2752
2798
|
|
|
2753
|
-
/**
|
|
2754
|
-
* The line an operator reads.
|
|
2755
|
-
*
|
|
2756
|
-
* States the outcome first. "An import ran" is not the question — "did it
|
|
2757
|
-
* finish, and what did it bring" is.
|
|
2758
|
-
*/
|
|
2759
|
-
export declare const describeImportRun: (run: ImportRun) => string;
|
|
2760
|
-
|
|
2761
2799
|
/**
|
|
2762
2800
|
* The TYPE of every binding in a row, and never a value.
|
|
2763
2801
|
*
|
|
@@ -2782,6 +2820,14 @@ export declare const describeImportRun: (run: ImportRun) => string;
|
|
|
2782
2820
|
*/
|
|
2783
2821
|
export declare const describeRowBindings: (row: Readonly<Record<string, unknown>>) => string;
|
|
2784
2822
|
|
|
2823
|
+
/**
|
|
2824
|
+
* The line an operator reads.
|
|
2825
|
+
*
|
|
2826
|
+
* States the outcome first. "An import ran" is not the question — "did it
|
|
2827
|
+
* finish, and what did it bring" is.
|
|
2828
|
+
*/
|
|
2829
|
+
export declare const describeTransferRun: (run: DataTransferRun) => string;
|
|
2830
|
+
|
|
2785
2831
|
/**
|
|
2786
2832
|
* Parse JSON-stringified array values back to JS arrays on the read
|
|
2787
2833
|
* side. Tolerates `null` (NULL column → null in JS), pre-deserialised
|
|
@@ -3581,22 +3627,6 @@ export declare type IdSchemeInput = undefined | {
|
|
|
3581
3627
|
|
|
3582
3628
|
export declare type IdSchemeKind = 'typeid' | 'ulid' | 'numeric' | 'snowflake' | 'custom';
|
|
3583
3629
|
|
|
3584
|
-
export declare const IMPORT_RUNS_TABLE = "_voltro_data_imports";
|
|
3585
|
-
|
|
3586
|
-
/** One import, as the inspector reads it back. */
|
|
3587
|
-
export declare interface ImportRun {
|
|
3588
|
-
readonly id: string;
|
|
3589
|
-
readonly startedAt: Date;
|
|
3590
|
-
readonly finishedAt: Date | null;
|
|
3591
|
-
readonly mode: string;
|
|
3592
|
-
readonly via: string;
|
|
3593
|
-
readonly bundle: string | null;
|
|
3594
|
-
readonly sourceFingerprint: string | null;
|
|
3595
|
-
readonly tablesWritten: number;
|
|
3596
|
-
readonly rowsWritten: number;
|
|
3597
|
-
readonly failure: string | null;
|
|
3598
|
-
}
|
|
3599
|
-
|
|
3600
3630
|
export declare interface IndexAuditIssue {
|
|
3601
3631
|
readonly kind: IndexAuditIssueKind;
|
|
3602
3632
|
readonly table: string;
|
|
@@ -7794,6 +7824,16 @@ export declare const _voltroApiKeysTable: TableLike;
|
|
|
7794
7824
|
|
|
7795
7825
|
export declare const _voltroCdcOffsetsTable: TableLike;
|
|
7796
7826
|
|
|
7827
|
+
/**
|
|
7828
|
+
* One import, as an operator asks about it.
|
|
7829
|
+
*
|
|
7830
|
+
* Deliberately small. Everything here answers a question somebody has actually
|
|
7831
|
+
* asked while looking at unexpected data — "where did this come from", "when",
|
|
7832
|
+
* "did it finish" — and nothing here is a per-row fact, because that is the
|
|
7833
|
+
* thing this replaces.
|
|
7834
|
+
*/
|
|
7835
|
+
export declare const _voltroDataTransfersTable: TableLike;
|
|
7836
|
+
|
|
7797
7837
|
/**
|
|
7798
7838
|
* `_voltro_idempotency` — one row per (scope, key) for HTTP idempotency
|
|
7799
7839
|
* (the `Idempotency-Key` header on REST routes). `scope` namespaces the key
|
|
@@ -7804,16 +7844,6 @@ export declare const _voltroCdcOffsetsTable: TableLike;
|
|
|
7804
7844
|
*/
|
|
7805
7845
|
export declare const _voltroIdempotencyTable: TableLike;
|
|
7806
7846
|
|
|
7807
|
-
/**
|
|
7808
|
-
* One import, as an operator asks about it.
|
|
7809
|
-
*
|
|
7810
|
-
* Deliberately small. Everything here answers a question somebody has actually
|
|
7811
|
-
* asked while looking at unexpected data — "where did this come from", "when",
|
|
7812
|
-
* "did it finish" — and nothing here is a per-row fact, because that is the
|
|
7813
|
-
* thing this replaces.
|
|
7814
|
-
*/
|
|
7815
|
-
export declare const _voltroImportRunsTable: TableLike;
|
|
7816
|
-
|
|
7817
7847
|
/**
|
|
7818
7848
|
* `_voltro_kv` — the durable key-value store behind `ctx.kv` / the `Kv`
|
|
7819
7849
|
* service when `KV_BACKEND=database` (the default for sql apps). One row per
|