@voltro/data-transfer 0.49.0 → 0.50.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/CHANGELOG.md CHANGED
@@ -39,6 +39,120 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.50.1] — 2026-08-24
43
+
44
+ ### Added
45
+
46
+ - **@voltro/cli** — A `0.51.0` upgrade note for the case 0.45.0's typed-`source:` note left open: a source that is COMPUTED but whose names are all known — a generic reader that takes its table from `input` or a registry. Both remedies the original offered are wrong there. There is no misspelled name to fix, and widening to `ReactivitySourceValue` (or casting) compiles instantly while taking that entire set of tables permanently out of the check the narrowing exists to provide.
47
+
48
+ The note carries the recipe that keeps the names — `as const satisfies`, with the key set recovered separately — and the trap under it: an ANNOTATION widens the keys back even when the literal carries `as const`, because it is checked against the literal and then replaces its type. Filed under an unreached version because codemod selection is `from < version <= to`: 0.45.0's note can never fire again for anyone already past it. Documented on the subscriptions page in both languages.
49
+
50
+ ### Changed
51
+
52
+ - **@voltro/data-transfer** — The `mariadb-dump`-not-on-PATH hint now also warns that a MariaDB 12.x client requires TLS by default, so running it BY HAND against a server without TLS fails with `TLS/SSL error: SSL is required` (2026) and needs `--skip-ssl`. Our own invocation is unaffected. It is said here because this hint is what sends people to install that client package, and the next thing many of them do is run the tool by hand — where the failure reads like a broken install of the thing we just told them to install.
53
+
54
+ ### Fixed
55
+
56
+ - **@voltro/cli, @voltro/mcp** — `voltro check`'s `rbac/unguarded-mutation` no longer fires on `internal: true` procedures. Those are in no rpc group and on no route, so the finding's own sentence — "any caller who can reach the rpc surface can invoke it" — named a surface that does not exist, and neither remedy it offered was available: a guard protects nothing there, and `openAccess` is refused outright on an internal descriptor. An app with 990 internal mutations got 990 warnings and a `FAILED` exit from the same tree on which `voltro doctor` reported zero procedures without an access decision, which made `check` unusable as the CI gate it exists to be.
57
+
58
+ The capability manifest now carries `internal: true` per procedure (present only when true), and the rule reads it through `isWireReachable` — the same predicate the boot access gate and all three rpc-group assemblies use, rather than a fourth spelling of the same flag. A manifest that does not carry the field is read as REACHABLE, so the rule stays loud on an api older than the field rather than going quiet on it.
59
+ - **@voltro/data-transfer, @voltro/cli** — `--assets` aborted the whole capture at the first blob reference the storage provider could not resolve. A dangling reference is a fact about the source data — a row pointing at an object that was deleted, or that never arrived because an earlier import ran without the flag — and no backup can put back bytes that are not there. Aborting made the flag unusable for exactly the deployment that needed it: 178 references, one resolvable, and the run stopped at the second.
60
+
61
+ The phase now records the key, steps over it, and the run reports how many were skipped. Only a genuine not-found (`status === 404`) is treated this way; a 403 from a rotated credential or a 5xx from a backend outage still fails the capture, because calling those "the object is gone" turns a recoverable outage into a backup that quietly contains nothing.
62
+
63
+ The same abort also cost the artefact its provenance: `voltro-backup-stamp.json` was written after the asset phase, so a backup taken WITH `--assets` had no stamp at all, and `restore` then greeted an artefact this tool had written minutes earlier as "an older/handmade backup. Cannot verify dialect or schema version." The stamp is now written on every path — it describes the dump, and the dump is on disk and correct by the time the assets run.
64
+ - **@voltro/cli** — `voltro doctor`'s eager-loaded-relation rule resolves nested relations against their PARENT's target table instead of against the query's roots, so every level is reported in one pass. It flattened the `.with({ … })` tree before resolving, which meant a level-2 relation stayed invisible until level 1's table had been added to `source:` — each fix revealed the next level, and a clean run after the first fix meant nothing. One app ran `doctor → fix → doctor` twice before the output stopped producing new findings.
65
+
66
+ The one case that is still genuinely under-reported is now stated instead of being silent: when the executor's base table is neither declared nor textually readable, nothing resolves, and doctor prints which relation names it could not check rather than reporting clean.
67
+ - **@voltro/data-transfer** — A native restore whose client exited before consuming its input took the whole CLI down with an unhandled `EPIPE`. `createReadStream(dump).pipe(child.stdin)` had no `error` listener, so Node threw on a write to a pipe with no reader:
68
+
69
+ Error: write EPIPE Emitted 'error' event on Socket instance at: at Socket.onerror (node:internal/streams/readable:1045:14)
70
+
71
+ What that cost is the point. The crash landed before `close`, so the step never resumed: the client's stderr — the one place the reason was written down — was discarded, the transfer row was never closed, the in-progress marker was never re-asserted, and the operator got a raw Node stack trace over a database that was now half replaced. A deployment met it on a 64 MB restore and could not diagnose it at all, because the only diagnosis had been thrown away.
72
+
73
+ Every stream in the step now carries a handler. `EPIPE` on the child's stdin is deliberately swallowed — a child closes the pipe by dying, and its exit code and stderr are the actual failure — while any other stream error is carried and reported. The failure line now always includes the tool's stderr (and says so explicitly when the tool printed none), plus how many bytes of the artefact had been fed before it stopped. A source error also ends the child's stdin, which turns a restore that used to hang forever on a vanished dump into one that fails, and a clean exit over a broken input stream is reported as a failure rather than as a truncated success.
74
+ - **@voltro/cli** — `voltro check`'s observed-vs-declared findings advised an op that does not exist. The recorder reports what the store did, and `store.upsert` is one call; a `target:` is `InsertTarget | UpdateTarget | DeleteTarget` and has no `upsert` member. So `observed/undeclared-write` said to add `{ table: '…', op: 'upsert' }` — a `TS2322`, from a line whose whole purpose is to be pasted. It now advises both halves, and the observed → declarable mapping is typed `Record<ObservedWriteOp, ReadonlyArray<TargetSpec['op']>>` so a new recorder op cannot ship without a declarable answer.
75
+
76
+ The remedy no longer produces a finding of its own either: declared targets are now collected per table as a SET. `new Map(targets.map(t => [t.table, t.op]))` kept only the last op, so the correct two-entry declaration read as "declares update" and the insert half came back as a `wrong-op`.
77
+ - **@voltro/data-transfer, @voltro/cli** — The in-progress restore marker did not survive a native restore, on the exact dialects that were documented as safe. The claim — postgres and the mysql family drop only the objects the dump names, so the marker row survives — had a correct argument and a wrong premise: a native dump names the WHOLE database, `_voltro_replace_in_progress` included, and a mysql-family restore writes `DROP TABLE IF EXISTS` in front of each table. The table sorts early, so the guard was removed near the START of the window it exists to cover. Measured downstream as one row before and zero after, twice, once by hand and once through the command — and then a restore died and left a database with a schema, some of its tables, no users and no blobs, with nothing to stop the next boot.
78
+
79
+ Two changes, covering different dumps. `voltro data backup` now excludes the marker table (`--exclude-table` / `--ignore-table`), so an artefact we produce cannot carry the thing that erases the guard on the way back in. And `restore` re-asserts the marker after the tool exits, on the failing path as well as the succeeding one, which covers dumps taken before this change and dumps made by hand: rewritten is a warning, and unwritable is an error, because the guard is then off for that run.
80
+ - **@voltro/plugin-storage, @voltro/cli** — `--assets` could not be refused when no storage was configured, and resolved the wrong backend when it was.
81
+
82
+ `resolveStorageProvider({})` is total: its final `default:` arm returns an in-process `memoryProvider`. So the three `if (!provider)` refusals in `voltro data backup` / `export` / `restore` — whose entire job is to refuse a flag the app cannot honour — were checking a condition that cannot hold. What they let through is worse than an unchecked flag: with no storage configured, `backup --assets` captured from a fresh memory provider, found nothing in it, and wrote an artefact stamped `assets: { count: 0 }` — a rollback story that says the blobs are in there.
83
+
84
+ It also ignored the provider the app REGISTERED. An app on `storagePlugin({ provider: s3(…) })` had its export/import/backup read and write the env-derived default instead, which surfaces later as "no object at key" — the exact drift `appStorageProvider()` exists to prevent, in call sites that never adopted it.
85
+
86
+ `configuredStorageProvider()` is the honest predicate: the app's registered provider, else the env-named one, else `undefined`. A memory provider nobody asked for is not a decision. The CLI now loads the app config BEFORE resolving — `storagePlugin(...)` registers at construction, so asking first answered with the default no matter what the app had configured.
87
+
88
+ ### Internal (no consumer-facing effect)
89
+
90
+ - **@voltro/cli** — `voltro data backup` / `restore` / `clear-replace-marker` are now driven end to end, one case per declared option and one per refusal, as real CLI subprocesses against a real database.
91
+
92
+ Every defect this command has shipped lived in the SEQUENCE rather than in a function — an unhandled `EPIPE` that discarded the client's stderr before `close` fired, a marker erased by the restore's own artefact, an asset abort that skipped the provenance stamp, a refusal that could not fire — so none of them was reachable by testing a part. `nativeBackupRestore.e2e.test.ts` covers the whole surface against sqlite (a file copy: no vendor binary, runs anywhere) and `nativeBackupRestoreDialects.integration.test.ts` runs the vendor-tool half against postgres, mariadb and mysql, skipping BY NAME when the server or the client binary is absent — including when the client is present but too old for the server, which a "is it on PATH" check reports as ready.
93
+
94
+ The suite checks itself against `DATA_FLAGS`, the command's own declared option list, so an option cannot be added without a case that drives it.
95
+
96
+ ---
97
+
98
+ ## [0.50.0] — 2026-08-23
99
+
100
+ ### ⚠ BREAKING
101
+
102
+ - **@voltro/cli** — The read-only run-history endpoint moved:
103
+
104
+ GET /_voltro/admin/imports → GET /_voltro/admin/transfers
105
+
106
+ Same secret, same query parameters, same response shape. Only the path changed.
107
+
108
+ It answers for four directions now — import, export, native backup, native restore — and it named one of them. The subcommand and the table were renamed for exactly that reason in 0.49.0 and this path was left behind, which is worse than renaming none of them: a reader who follows a rename tries the matching path, gets a 404, and concludes the instance is too old.
109
+
110
+ `voltro data transfers --target api` uses the new path for you. What needs a hand is anything calling it directly — a monitoring check, an uptime probe, a curl in a runbook, a dashboard datasource. The codemod is `manual` and declares `reach: 'beyond-source'`, so it prints whether or not the path is found in your repository.
111
+ - **@voltro/database, @voltro/voltro** — `InterruptedReplace.tables` is `number | null`, and the interface gains `kind?: 'replace' | 'restore'`.
112
+
113
+ `_voltro_replace_in_progress` records two destructive operations now — an import's `--mode replace` and a native `voltro data restore`. A restore replaces the whole database from an artefact, so "how many tables was this going to empty and refill" has no answer: not known up front, not meaningful after.
114
+
115
+ Writing `0` would have preserved the type and been worse. That number is rendered into the boot refusal, which is read under pressure, and it would have said `began emptying 0 table(s)` — a measurement that was never taken. The framework's own text says "this database" instead; `Number(null)` is `0`, so coercing it reintroduces exactly the sentence being avoided.
116
+
117
+ `DataTransferRun.direction` also widens to name `'backup'` and `'restore'` explicitly. That one is documentary — the union already ended in `| string`, so no assignability changes.
118
+
119
+ **`voltro update` carries you across this** — codemod `0.50.0/03_interrupted-replace-tables-nullable`.
120
+
121
+ ### Added
122
+
123
+ - **@voltro/cli, @voltro/data-transfer, @voltro/database** — `voltro data backup --assets` and `voltro data restore --assets` now move the stored blobs alongside the vendor dump, through the same content-addressed phase the logical `export` / `import` path uses — streamed, deduped by sha256, verified on the way back, resumable per key.
124
+
125
+ `--assets` was accepted by `backup` and silently ignored, with the only signal a field in the closing JSON reading `NOT included`; `restore` did not accept it at all. A rows-only backup restores a database whose rows reference objects nothing puts back, and the reference and the object are checked at different times, so that state is discovered by a user rather than by the restore.
126
+
127
+ Three refusals, each for a belief that is otherwise acted on silently: `backup --assets` with no storage provider is refused rather than swallowed; `restore --assets` on a rows-only artefact is refused; a restore WITHOUT `--assets` over an artefact that has them warns and proceeds, because restoring rows without blobs is legitimate and refusing it would push people at `--force`.
128
+
129
+ The dump itself still has no resume — a vendor artefact is one opaque file with no offset to restart from, and the logical path is what exists for that.
130
+ - **@voltro/cli, @voltro/database, @voltro/data-transfer** — A native `backup` / `restore` now writes to the same `_voltro_data_transfers` record `import` and `export` use, so `voltro data transfers` answers "did last night's backup finish" from the instance that ran it. A native run reports blobs rather than rows — a vendor tool reports no row count we can trust, and printing `0 row(s)` over a dump that worked would be a wrong measurement.
131
+
132
+ `restore` also writes the `_voltro_replace_in_progress` marker before its first destructive statement and clears it after the last write, blobs included, so a killed restore refuses the next boot instead of serving a half-loaded database. `--allow-live` guards from the wrong side — it asks you not to — and this guards from the right one. The marker carries a `kind` so the refusal can say something different for a `replace` (re-import the capture) and a `restore` (finish the restore), and `tables` is nullable because a native restore has no table count to claim.
133
+
134
+ The sqlite / turso restore is atomic now (temp file + rename): its marker lives in the very file being replaced, so a plain in-place copy would leave a truncated database with nothing left to catch it.
135
+
136
+ A target with no `_voltro_data_transfers` table still gets its backup; the closing line says it was not recorded rather than implying it was.
137
+ - **@voltro/cli** — A re-issued migration note for the `voltro data imports` → `voltro data transfers` rename that shipped in 0.49.0.
138
+
139
+ Codemods are selected by `from < version <= to`, so the 0.49.0 note fires once, on the jump that crosses 0.49.0, and cannot be corrected for anyone already past it. Its gate searched `.ts` / `.tsx` while the command it is about lives in shell scripts, CI job definitions and runbooks — so a project whose only occurrence sat in `.gitlab-ci.yml` crossed 0.49.0 and was told there was nothing to apply.
140
+
141
+ The re-issue is filed under 0.50.0, prints unconditionally, and says what to grep for. Redundant for anyone already fixed; the alternative is firing for nobody.
142
+
143
+ ### Fixed
144
+
145
+ - **@voltro/cli** — A `manual` codemod's `appliesTo` can now search every text file the project owns — `.sh`, `.yml`, `.json`, `.md`, `Makefile`, the `.js` scripts — through a new `ctx.text` on the predicate context, and a codemod may declare `reach: 'beyond-source'` to print its note even when nothing matched.
146
+
147
+ Both halves close the same gap, and it was in the codemod most in need of a gate. A manual codemod exists BECAUSE its subject could not be transformed, which usually means it is not source at all — and `appliesTo` was reading the ts-morph project, which holds `.ts` / `.tsx` and nothing else. Measured with one identical CLI invocation in four files: the `.ts` one printed the note, the `.sh`, `.yml` and `.md` ones printed nothing, and the run reported `codemods: nothing to apply for this jump`. That is an acquittal from a check that never looked at the file, and an acquittal gets acted on.
148
+
149
+ `reach: 'beyond-source'` covers what no scan of one repository can reach — an inline script in a CI runner's own UI, a CronJob spec in another repo, a wiki runbook. The note prints either way; only its framing changes, and an uncertain one says plainly that we could not look there.
150
+ - **@voltro/data-transfer** — When `mariadb-dump` is absent and the mysql-family fallback runs Oracle's `mysqldump` against a MariaDB server, the failure now names the way out.
151
+
152
+ The stderr it prints is the child's own words and is the right first thing to show — and on its own it is a dead end: `Unknown table 'COLUMN_STATISTICS' in information_schema (1109)` names a table nobody asked for, in a schema nobody wrote, about a feature nobody enabled. Everything needed to act on it was known where the fallback was DECIDED: which binary we wanted, which one we took, and why the difference matters. That travels with the step now and prints under the stderr, including the counter-move a reader reaches for on their own (`--column-statistics=0` does not exist on `mariadb-dump`, so it fixes the wrong client and breaks the right one).
153
+
154
+ ---
155
+
42
156
  ## [0.49.0] — 2026-08-23
43
157
 
44
158
  ### ⚠ BREAKING
package/dist/index.d.ts CHANGED
@@ -76,6 +76,23 @@ export declare interface AssetInfo {
76
76
  readonly size: number;
77
77
  }
78
78
 
79
+ /**
80
+ * The resume journal, as this phase needs it.
81
+ *
82
+ * Deliberately two functions rather than the `Ledger` type: the native path
83
+ * keeps its own sidecar and the logical path keeps the shared one, and neither
84
+ * has any business knowing the other's file layout. What both must agree on is
85
+ * the SEMANTICS — `done` is keyed by the asset KEY (not its hash), because an
86
+ * asset is skippable when the destination already has that key, and the hash is
87
+ * not known until the bytes have been read, which is the cost being avoided.
88
+ */
89
+ export declare interface AssetProgress {
90
+ readonly done: (key: string) => boolean;
91
+ /** Record `key` as landed. Called AFTER the bytes are durable, never before —
92
+ * a ledger written first turns a crash into silent data loss on resume. */
93
+ readonly mark: (key: string, entry: AssetEntry) => Effect.Effect<void, BundleError>;
94
+ }
95
+
79
96
  export declare const ASSETS_DIR = "assets";
80
97
 
81
98
  /** Where import writes assets TO. */
@@ -149,6 +166,41 @@ export declare type CanonicalCategory = 'string' | 'integer' | 'float' | 'boolea
149
166
  * types (a bundle from a newer framework) fall back to 'string' passthrough. */
150
167
  export declare const canonicalType: (type: string) => CanonicalCategory;
151
168
 
169
+ /**
170
+ * Stream every asset the source enumerates into the content-addressed `assetsDir`.
171
+ *
172
+ * `assetsDir` must exist. Each asset is hashed while it streams (never buffered
173
+ * whole), written to a temp file and renamed to `assets/<sha256>` — so identical
174
+ * blobs dedupe, a concurrent reader never sees a half-written asset, and the
175
+ * hash IS the integrity check the restore verifies against.
176
+ */
177
+ export declare const captureAssetsToCas: (opts: {
178
+ readonly source: AssetSource;
179
+ readonly assetsDir: string;
180
+ readonly progress?: AssetProgress;
181
+ }) => Effect.Effect<CapturedAssets, BundleError>;
182
+
183
+ export declare interface CapturedAssets {
184
+ readonly count: number;
185
+ readonly totalBytes: number;
186
+ /**
187
+ * Keys the refs table names and the provider does not have (404).
188
+ *
189
+ * A DANGLING REFERENCE IS NOT A CAPTURE FAILURE. It is a fact about the source
190
+ * data — a row pointing at an object that was deleted, or that never arrived
191
+ * because an earlier import ran without `--assets`. Aborting the phase on one
192
+ * made `--assets` unusable for exactly the deployment that needed it most: 178
193
+ * references, one resolvable, and the run stopped at the second. What it left
194
+ * behind was an `assets/` directory with a single blob, no provenance stamp,
195
+ * and no statement anywhere that 177 objects had been skipped — so the artefact
196
+ * read as a complete asset backup.
197
+ *
198
+ * Reported and carried, never swallowed: the count goes in the stamp so the
199
+ * restore can say what it is about to under-restore.
200
+ */
201
+ readonly missing: ReadonlyArray<string>;
202
+ }
203
+
152
204
  /**
153
205
  * Lint a bundle's column types against a target dialect. Same-dialect import is
154
206
  * always clean (returns []). Otherwise returns every column whose type won't
@@ -1075,6 +1127,9 @@ export declare type NativeStep = {
1075
1127
  readonly env: Readonly<Record<string, string>>;
1076
1128
  readonly stdoutFile?: string;
1077
1129
  readonly stdinFile?: string;
1130
+ /** Something known at BUILD time that the failure could not otherwise
1131
+ * say — e.g. that this tool is a fallback for one that was absent. */
1132
+ readonly hint?: string;
1078
1133
  } | {
1079
1134
  readonly kind: 'copy';
1080
1135
  readonly from: string;
@@ -1089,6 +1144,19 @@ export declare class NativeToolError extends NativeToolError_base<{
1089
1144
  readonly tool: string;
1090
1145
  readonly reason: string;
1091
1146
  readonly stderr?: string;
1147
+ /**
1148
+ * What the CALLER knew and the child could not say.
1149
+ *
1150
+ * The stderr above is the tool's own words, which is the right first answer
1151
+ * and is sometimes a dead end on its own: `Unknown table 'COLUMN_STATISTICS'
1152
+ * in information_schema (1109)` names a table nobody asked for, in a schema
1153
+ * nobody wrote. The fact that turns it into an action — that we wanted
1154
+ * `mariadb-dump`, could not find it, and took Oracle's `mysqldump` instead —
1155
+ * is known where the step is BUILT and nowhere else. So it travels with the
1156
+ * step (`NativeStep.hint`) and is printed under the child's words, never
1157
+ * instead of them.
1158
+ */
1159
+ readonly hint?: string;
1092
1160
  }> {
1093
1161
  /**
1094
1162
  * The child's own words, not ours.
@@ -1117,6 +1185,11 @@ declare const NativeToolError_base: new <A extends Record<string, any> = {}>(arg
1117
1185
  * rather than a bare SyntaxError. */
1118
1186
  export declare const ndjsonToRows: <E, R>(bytes: Stream.Stream<Uint8Array, E, R>, table: string, columnTypes: ColumnTypes) => Stream.Stream<Row, E | CodecError, R>;
1119
1187
 
1188
+ /** A progress journal that remembers nothing — every asset is transferred. Used
1189
+ * where there is no sidecar to keep, and named so a caller passing it is
1190
+ * saying "no resume" rather than passing `undefined` and hoping. */
1191
+ export declare const noAssetProgress: AssetProgress;
1192
+
1120
1193
  export declare type OnConflict = 'skip' | 'fail';
1121
1194
 
1122
1195
  /** The caller's progress sink. Plain sync fn — never fails the job. */
@@ -1232,6 +1305,9 @@ export declare interface ProgressEvent {
1232
1305
  /** Which pipeline the event belongs to. */
1233
1306
  export declare type ProgressPhase = 'export' | 'import';
1234
1307
 
1308
+ /** Read a CAS index file (NDJSON, one {@link AssetEntry} per line) as a stream. */
1309
+ export declare const readAssetIndex: (indexPath: string) => Stream.Stream<AssetEntry, BundleError>;
1310
+
1235
1311
  /** Read the ledger at `path`, or an empty one when it is absent / unreadable
1236
1312
  * (a missing ledger just means "nothing done yet" — never a hard failure). */
1237
1313
  export declare const readLedger: (path: string) => Effect.Effect<Ledger>;
@@ -1270,6 +1346,20 @@ export declare const restoreAssetFromCas: (sink: AssetSink, assetsDir: string, e
1270
1346
  readonly contentType: string;
1271
1347
  }) => Effect.Effect<void, BundleError | IntegrityError | StorageError>;
1272
1348
 
1349
+ /**
1350
+ * Push every asset named in the index back to the sink, re-hashing on the way.
1351
+ *
1352
+ * A hash mismatch is an {@link IntegrityError} and stops the phase — a corrupted
1353
+ * artefact must never silently re-upload bad bytes over good ones, which is the
1354
+ * one failure a restore has no way to notice afterwards.
1355
+ */
1356
+ export declare const restoreAssetsFromCas: (opts: {
1357
+ readonly sink: AssetSink;
1358
+ readonly assetsDir: string;
1359
+ readonly indexPath: string;
1360
+ readonly progress?: AssetProgress;
1361
+ }) => Effect.Effect<number, BundleError | IntegrityError | StorageError>;
1362
+
1273
1363
  /** Build the restore step for a dialect reading `inFile`. */
1274
1364
  export declare const restoreCommand: (dialect: string, conn: NativeConn, inFile: string) => NativeStep;
1275
1365